Python Project Report
Python Project Report
INTRODUCTION
1.1 PYTHON:
2
1.1.2 History of Python
Python was developed by Guido van Rossum in the late eighties and early nineties at
the National Research Institute for Mathematics and Computer Science in the
Netherlands.
Python is derived from many other languages, including ABC, Modula-3, C, C++,
Algol-68, SmallTalk, and Unix shell and other scripting languages.
Python is copyrighted. Like Perl, Python source code is now available under the GNU
General Public License (GPL).
Python is now maintained by a core development team at the institute, although Guido
van Rossum still holds a vital role in directing its progress.
But there are some future technologies that are relying on python. As a matter of fact,
Python has become the core language as far as the success of these technologies is
concerned. Let’s dive into the technologies which use python as a core element for
research, production and further developments.
There are plenty of python frameworks, libraries, and tools that are specifically
developed to direct Artificial Intelligence to reduce human efforts with increased
accuracy and efficiency for various development purposes.
It is only the Artificial Intelligence that has made it possible to develop speech
recognition system, autonomous cars, interpreting data like images, videos etc.
We have shown below some of the python libraries and tools used in various
Artificial Intelligence branches.
The future scope of python programming language can also be predicted by the way it
has helped big data technology to grow. Python has been successfully contributing in
analyzing a large number of data sets across computer clusters through its high-
performance toolkits and libraries.
Let’s have a look at the python libraries and toolkits used for Data analysis and
handling other big data issues.
Pandas
Scikit-Learn
NumPy
SciPy
GraphLab Create
IPython
Bokeh
Agate
PySpark
Dask
(3) Networking
Networking is another field in which python has a brighter scope in the future. Python
programming language is used to read, write and configure routers and switches and
perform other networking automation tasks in a cost-effective and secure manner.
For these purposes, there are many libraries and tools that are built on the top of the
python language. Here we have listed some of these python libraries and tools
especially used by network engineers for network automation.
Ansible
Netmiko
Junos PyEZ
PySNMP
Paramiko SSH
Python programming language is used for web development, so here are some of the
world’s most popular websites that are created using python.
Youtube
Quora
Spotify
Flipkart
Uber
Facebook
Fig 1.4 Companies Using Python
Why Python Programming Language Has Bright Future?
Python has been voted as most favourite programming language beating C, C++ and
java programming. Python programming is open source programming language and
used to develop almost every kind of application.
Python programming is used to write test scripts and tests mobile devices
performance. It is one of the most versatile languages these days. Python
programmers are most demandable in the IT industry these days and get paid more
compared to another language programmer.
A module allows you to logically organize your Python code. Grouping related code
into a module makes the code easier to understand and use. A module is a Python
object with arbitrarily named attributes that you can bind and reference.
Simply, a module is a file consisting of Python code. A module can define functions,
classes and variables. A module can also include runnable code.
Example
The Python code for a module named a name normally resides in a file named
aname.py. Here's an example of a simple module, support.py
return
You can use any Python source file as a module by executing an import statement in
some other Python source file. The import has the following syntax −
When the interpreter encounters an import statement, it imports the module if the
module is present in the search path. A search path is a list of directories that the
interpreter searches before importing a module. For example, to import the module
support.py, you need to put the following command at the top of the script −
#!/usr/bin/python
import support
support.print_func("Jerry")
Hello : Jerry
A module is loaded only once, regardless of the number of times it is imported. This
prevents the module execution from happening over and over again if multiple
imports occur.
For example, to import the function fibonacci from the module fib, use the following
statement −
This statement does not import the entire module fib into the current namespace; it
just introduces the item fibonacci from the module fib into the global symbol table of
the importing module.
For example, here is a valid "Hello, world!" web application with Flask:
The above code shows "Hello, World!" on localhost port 5000 in a web browser when
run with the python app.py command and the Flask library installed.
Flask was also written several years after Django and therefore learned from the
Python community's reactions as the framework evolved. Jökull Sólberg wrote a great
piece articulating to this effect in his experience switching between Flask and Django
1.3.1 FLASK INSTALLATION
We recommend using the latest version of Python 3. Flask supports Python 3.3 and
newer, Python 2.6 and newer, and PyPy.
Jinja isa template language that renders the pages your application serves.
Click isa framework for writing command line applications. It provides theflask
command and allows adding custom management commands.
Virtual environments
Use a virtual environment to manage the dependencies for your project, both in de-
velopment and in production.
What problem does a virtual environment solve? The more Python projects you have,
the more likely it is that you need to work with different versions of Python libraries,
or even Python itself. Newer versions of libraries for one project can break
compatibility in another project.
Virtual environments are independent groups of Python libraries, one for each project.
Packages installed for one project will not affect other projects or the operating sys-
tem’s packages.
Flask leverages Jinja2 as template engine. You are obviously free to use a different
tem-plate engine, but you still have to install Jinja2 to run Flask itself. This
requirement is necessary to enable rich extensions. An extension can depend on Jinja2
being present.
This section only gives a very quick introduction into how Jinja2 is integrated into
Flask. If you want information on the template engine’s syntax itself, head over to the
official Jinja2 Template Documentation for more information.
Jinja Setup
1. autoescaping is enabled for all templates ending in .html, .htm, .xml as well as
3. a template has the ability to opt in/out autoescaping with the {% autoescape %}
tag.
4. Flask inserts a couple of global functions and helpers into the Jinja2 context, ad-
ditionally to the values that are present by default.
Standard Context
The following global variables are available within Jinja2 templates by default:
config
Changed in version 0.10: This is now always available, even in imported tem-
plates.
request
session
The request-bound object for global variables (flask.g). This variable is unavail-
able if the template was rendered without an active request context.
url_for()
get_flashed_messages()
A database stores application data in an organized way. The application then issues
queries to retrieve specific portions as they are needed. The most commonly used
databases for web applications are those based on the relational model, also called
SQL databases in reference to the Structured Query Language they use. But in recent
years document-oriented and key-value databases, informally known together as
NoSQL databases, have become popular alternatives.
Relational databases store data in tables, which model the different entities in the ap‐
plication’s domain. For example, a database for an order management application will
likely have customers, products, and orders tables. A table has a fixed number of
columns and a variable number of rows. The columns define the data attributes of the
entity represented by the table. For example, a customers table will have columns
such as name, address, phone, and so on. Each row in a table defines an actual data
element that consists of values for all the columns. Tables have a special column
called the primary key, which holds a unique identifier for each row stored in the
table. Tables can also have columns called foreign keys, which reference the primary
key of another row from the same or another table. These links between rows are
called relationships and are the foundation of the relational database model.
Python has packages for most database engines, both open source and commercial.
Flask puts no restrictions on what database packages can be used, so you can work
with MySQL, Postgres, SQLite, Redis, MongoDB, or CouchDB if any of these is
your favorite. As if those weren’t enough choices, there are also a number of database
abstraction layer packages such as SQLAlchemy or MongoEngine that allow you to
work at a higher level with regular Python objects instead of database entities such as
tables, documents, or query languages. There are a number of factors to evaluate
when choosing a database framework: Ease of use When comparing straight database
engines versus database abstraction layers, the second group clearly wins. Abstraction
layers, also called object-relational mappers (ORMs) or object-document mappers
(ODMs), provide transparent conversion of high-level object-oriented operations into
low-level database instructions.
1.6
Flask was originally designed and developed by Armin Ronacher as an April Fool's
Day joke in 2010. Despite the origin as a joke, the Flask framework became wildly
popular as an alternative to Django projects with their monolithic structure and
dependencies.
Flask's success created a lot of additional work in issue tickets and pull requests.
Armin eventually created The Pallets Projects collection of open source code libraries
after he had been managing Flask under his own GitHub account for several years.
The Pallets Project now serves as the community-driven organization that handles
Flask and other related Python libraries such as Lektor, Jinja and several others.
Fig.1.5 Comparision
A web developer has option to choose from a wide range of web frameworks while
using Python as server-side programming languages. He can take advantage of the
full-stack Python web frameworks to accelerate development of large and complex
web applications by availing a number of robust features and tools. Likewise, he can
also opt for micro and lightweight Python web frameworks to build simple web
applications without putting extra time and effort.
Both Django and Flask are hugely popular among Python programmers. Django
is a full-stack web framework for Python, whereas Flask is a lightweight and
extensible Python web framework. Django is developed based on batteries-included
approach. It enables programmers to accomplish common web development tasks
without using third-party tools and libraries. Django lacks some of the robust features
provided by Python.
But it is developed based on two robust POCO projects – Web Server Gateway
Interface (WSGI) toolkit and Jinja2 template engine. The developers can take
advantage of WSGI to communicate web application and web server through a
universal interface. Likewise, Jinja2 template engine makes it easier for programmers
to build dynamic web applications. Hence, it becomes essential for web developers to
understand the major differences between Flask vs Django.
Flask is more Pythonic than Django because the code of flask Web Application in
most cases is more explicit than the Django Web Application code. So it is easy for
Python coders to pick up.
Beginners can learn a lot from the well documented Source Code.
Flask does include everything you need to start building something more complex
than the above Hello World app. It integrates a templating engine (Jinja2) for you so
you don't have to decide whether you would be better off using Genshi, Cheetah or
Mako (though you could use).
The extra work at start to choose components for Flask apps yields more flexibility
for developers whose use case doesn't fit a standard ORM, or who need to
interoperate with different workflows or templating systems.
Flask also scales well. Pinterest uses Flask for their API. The API Handles over 12
billion requests per day, all in Flask.
CHAPTER 2
This section is to present a detailed description of the Platforms used for this project.
It explains the hardware and software requirements for developing the application and
its interface, tested features of the program,
This program has been developed using 4 GB of RAM, i5 1.70 GHz 1 TB Hard disk
space but the Minimum requirement of such kind of application for a machine is:
DirectX 9-capable video card running at 1024 x 768 or higher display resolution.
IDLE – A GUI
based IDE that Open Source Windows, Mac https://www.python.org/downlo
comes pre- OS, Linux ad /
installed with the
reference
implementation
PyCharm – A GUI
based IDE by Windows, Mac http://www.jetbrains.com/pycha
Jetbrains Commercial/Free OS, Linux r m/download/
supporting code- Community Edition
completion, code-
debugging,
refactoring etc.
Anaconda is a free
and open source
distribution of
the Python and R Windows, Mac https://www.anaconda.com/dow
programming Free and Open OS, Linux nload/
languages for data Source
science and
machine learning
related
applications that
aims to simplify
package
management and
deployment
In this Project we have used PyCharm as an integrated development environment.
Fig1.6 PyCharm
SNAPSHOTS
SCREENSHOTS:
1) Home page.
This type of information helps companies develop better products and webmasters
produce more targeted content. Detailed information makes the economy more
efficient.
There was a good piece on GigaOM that discussed how Bit.ly could launch its own
version of Digg. While this may or may not be Bit.ly's eventual goal (just like Digg, a
URL shortener could be gamed), it's clear that the data that URL shorteners can
accumulate, coupled with the rise of short URL sharing on Twitter and other websites,
could amount to some innovative social media services that display popular links,
rank domains, and act as a filter or aggregate of social media content.
URL shorteners, in their own way, work as aggregates of information. This can lead
to some useful mashups and innovations in how people share and digest content.
A new URL shortener, Pagetweet, caught my eye. It's a little more complicated than
other URL shorteners (I don't understand why it requires a security code), but when
you look at an actual page via Pagetweet, it provides a useful interface for sharing via
social media, seeing the number of views, and more.
Because it's so easy for companies to enter this space, innovations are constantly
being made that improve the user experience. Digg recently launched a DiggBar and
Digg URL shortener, which provides information on the number of Diggs and
comments any article has received. This is only the beginning.
Users also have a choice - they can follow links that will provide features, or simply
choose ones with only the necessary functionality to get them to a web page. All in all
though, URL shorteners can improve the browsing experience.
You can simply fit more links and content in less space with URL shorteners. A tweet
can describe and then link to a webpage in under 140 characters, while a full URL
might not even come with an explanation.
Even more important is the rise of mobile smartphones, texting, and mobile Internet -
it's far easier to text in a short URL than a long one. As Twitter, social media, and
mobile Internet become more popular, the need to make sharing web content easier
will increase. Shorter URLs are becoming more and more integral to that cause.
If Geocities and Google Answers got shut down, so will these third-party URL
shortening services, especially if they are not profitable nor getting financial support.
We all hope this won’t happen but if it does, all the your links you connected with this
service will not work. Not even a 301 redirection will solve the issue. So that’s a risk
when you created these short URLs and placed them on offline channels for people to
view and access, suddenly they became broken links. Another major impact is that
your destination URL will also lose a portion of its inbound links that may or may not
impact your SEO efforts.
Every single URL generated by the URL shortening services like Bit.ly, Owl.ly,
TinyURL and Su.pr will show no clue about the destination URL. Wait, there’s a little
clue if the alias used provides descriptive hint, though I don’t expect it to be very
descriptive otherwise it might be too long that it’s no longer a short URL. With this
setup people might have hesitation on whether to click this link or not.
Since the destination landing page URL is not visible when it is shortened, people will
have no idea where they’ll land on once they click the link or type the short URL
address. Even if provided with a hint, that might just be a disguise to attract audience
and lead them to phishing sites or those that pose security issues such as those that
auto-download malicious programs that extract information from your machine or
phone.
If you are a big organization, part of your branding exercise should include even the
URL shortening service. Using generic short URLs don’t reveal your brand identity.
Pepsi (pep.si), Virgin (virg.in), BBC (bbc.in) and The New York Times (nyti.ms)
have their own custom link shortening service when sharing content on social media.
Using generic short URLs isn’t necessarily bad (discounting all the disadvantages I
listed here) but having your own custom URL can improve brand visibility and
consistency.
By using an extra layer of URL before forwarding to a destination landing page, there
exists an extra step in the journey of a visitor to a website. But even though 301
redirection method is supposed to be quick and painless, speed could be an issue
when bridging two sites of different technical backgrounds. A study in 2010 showed
that all of the 14 URL shortening services tested have significantly slowed down page
loading time. Seven years later, we can only hope these are already resolved.
Otherwise, this page loading speed issue which is one of search engine factors, might
impact search visibility of the landing page.
CHAPTER 5
5.1 CONCLUSION
This project work is an attempt to develop web application which can be used to
shorten the URL’s.
The main feature of our project is that it is time saving, as there are very long
URLs which are hard to remember. Also the software used in this project, python is a
flexible language which can run in any type of system. It is user friendly and very
easy to use.
URL shorteners offer a range of pros and cons, and it can be difficult to know
when it’s best to make use of them. However, knowledge is power, and studying the
positives and the negatives will offer some insight into whether they’re right for you.
This project has really been faithful and informative. It has made us learn and
understand the many trivial concepts of Python Language.Even more important is the
rise of mobile smartphones, texting, and mobile Internet - it's far easier to text in a
short URL than a long one. As Twitter, social media, and mobile Internet become
more popular, the need to make sharing web content easier will increase. Shorter
URLs are becoming more and more integral to that cause.
Every single URL generated by the URL shortening services like Bit.ly, Owl.ly,
TinyURL and Su.pr will show no clue about the destination URL. Wait, there’s a little
clue if the alias used provides descriptive hint, though I don’t expect it to be very
descriptive otherwise it might be too long that it’s no longer a short URL. With this
setup people might have hesitation on whether to click this link or not.
One of the reasons that it has received so much attention lately is because of the
comprehensive data Bitly provides in the form of live click data, geographic location,
the webpage the link where the link was clicked, and more. This type of information
is invaluable to webmasters and companies - it shows where customers are coming
from, when they are coming, and what interests them.
Flask is considered more Pythonic than the Django web framework because in
common situations the equivalent Flask web application is more explicit. Flask is also
easy to get started with as a beginner because there is little boilerplate code for getting
a simple app up and running.
Flask is more Pythonic than Django because the code of flask Web Application in
most cases is more explicit than the Django Web Application code. So it is easy for
Python coders to pick up.Beginners can learn a lot from the well documented Source
Code.
Flask does include everything you need to start building something more complex
than the above Hello World app. It integrates a templating engine (Jinja2) for you so
you don't have to decide whether you would be better off using Genshi, Cheetah or
Mako (though you could use).
The extra work at start to choose components for Flask apps yields more flexibility
for developers whose use case doesn't fit a standard ORM, or who need to
interoperate with different workflows or templating systems.
Django is a large framework which includes everything, whether you require it or not.
So for smaller application Flask can give more performance. httpbin is a smaller
application built with Flask.
The crux of it all is this: The simplest and most effective way to avoid the pitfalls is to
understand how link shorteners operate. Through this knowledge, you can seek to
understand how shortened URLs behave in different situations, enabling you to
harness the benefits for your own gain.
URL shortening services simply make hyperlink text look more attractive. Normally,
website URLs take up a bunch of space. They’re often unattractive strings of random
letters and numbers, and can be distracting and aesthetically unpleasing.
However, it’s more than just aesthetics. Shortened links make the reading experience
smoother, particularly on social media platforms. In addition, they make it easier for
your viewers to share content, as it’s less likely they’ll make an error when copying
over links (although this is less of a concern when using modern smartphones). Not
only that, but there’s no danger of losing any hard-won SEO benefits – Google are
smart enough to pass on link juice for any 301 or permanent redirects implemented.
There’s also click tracking to consider, and measuring the success of your marketing
efforts is always imperative. In a nutshell, you can’t improve on targeting your
audience if you don’t know how they respond to your content. Link shorteners
provide analytics to show you who has clicked your links
REFERENCE
1) https://en.wikipedia.org/wiki/Flask_(web_framework)
2) https://github.com/jerrysingh181/URL-SHORTENING
3) https://www.upgrad.com/
4) https://www.fullstackpython.com/flask.html
5) https://realpython.com/tutorials/flask/