Web Clients - Web Servers
Web Clients - Web Servers
Web Frameworks:
Intro to Web
Communication
CSE304 – Python Programming and Web Frameworks
Dr R Anushiadevi/SoC/SASTRA
Textbook: Wesley J Chun, Core PYTHON Applications Programming,
Prentice Hall, Third Edition, 2013
1
Introduction
Click to edit Master title style
3 3
Protocols
Click to edit&Master
the Internet
title style
➢ They are known as the Language of Communication between the Client
and the Server.
➢ The Standard Protocol used for Web Communication is called as
Hypertext Transfer Protocol [HTTP] which is written on top of the
Transmission Control Protocol – Internet Protocol Suite [TCP-IP Suite].
“
Expanded view
of the Internet
5 5
Network
Click Defenses
to edit Master title style
➢ Firewalls help fight unauthorized access to a corporate (or a home)
network by blocking down entry points that are configurable on a per-
network basis.
➢ These systems reduce the chances of hacking by locking down
everything and only opening up the ports for well-known services like
Web Servers and Secure Shell (SSH) or the Secured-Socket Layer (SSL).
➢ Proxy Servers are a useful tool for administrators to monitor network
traffic. They also cache data, because of which webpages load much
faster while at the same time give the information to the company
hosting the server as to what are their clients (in this case, their
employees) are using the Internet for.
➢ There are different kinds of Proxy Servers – the Forward Proxies and the
Reverse Proxies – based on which side’s information they are
programmed to record data for.
6 6
Server
Click to Farms
edit Master title style
➢ For companies with very large websites, they host their own Server
Farms located at their Internet Service Providers [ISP].
➢ Their physical location is known as the Co-Location – meaning that the
companies’ servers reside at an ISP along with computers with other
corporate customers.
➢ All the clients [Host Machines] are connected with the Server Farm with
a Network Backbone – following any desired Network Topology so the
clients are provided with faster access and being the backbone helps
the data transmitted to not suffer any packet-loss during transportation
from the server to the user.
➢ Some famous Server Farms across the globe include:
➢ Microsoft Data Center [1.2 Million sq.ft.]
➢ Yotta D1 Data Center [India’s Largest Server Farm]
➢ The Citadel [World Largest Server Farm – 7.2 Million sq.ft.]
7 7
Click to edit Master title style
Web Frameworks:
Python Web
Client Tools
CSE304 – Python Programming and Web Frameworks
Dr R Anushiadevi/SoC/SASTRA
Textbook: Wesley J Chun, Core PYTHON Applications Programming,
Prentice Hall, Third Edition, 2013
8
Introduction
Click to edit Master title style
➢ The Web Browser is not the only Web Client for accessing a Server.
➢ Most of the browsers provide only limited capacity – viewing and
interacting with websites [using Hypertext Markup Language (HTML),
eXtensible Markup Language (XML), etc…]
➢ However, a Client Program can Download Data, Store them, Manipulate
them or even Transmit them from one location (which is known as the
Sender) to another location (known as the Receiver).
➢ The way in which Web Browsers help us access Websites available in the
internet is by uniquely identifying them with what is known as the
Uniform Resource Locator [URL].
➢ They are also known as the Web Address of the webpage.
➢ In Python, the ‘urllib’ module helps in manipulating URL’s available in the
Internet.
9 9
Components
Click of antitle
to edit Master URLstyle
https://www.example.co.uk:443/blog/article/search?docid=720&hl=en#dayone
1010
Manipulating
Click URLstitle
to edit Master in Python
style
➢ In Python 2.x, Python provided 2 Modules – urlparse and urllib that deals
with URLs in completely different functionality and capabilities.
➢ However, both the modules have been deemed ‘Obsolete’ with the latest
versions of Python starting from 3.x; now both the modules have been
combined into one single module called urllib with the following 4 Library
Modules containing the functionalities:
The above named tuples can also be referred to with their index values starting
from 0 [Scheme] to 6 [Fragment].
1313
urllib.parse Library:
Click to edit Master title style
urllib.parse.urlunparse(), urljoin()
➢ urllib.parse.urlunparse ( urlparsetuple )
Construct an URL from a tuple returned from urlparse() function. The
‘urlparsetuple’ argument can be any 6-Item Iterable Tuple. For accurate
results, it is advised that only Tuples formed from the urlparse() function
is to be passed as an argument to the function. Returns a String.
1515
urllib.parse Library: Legacy
Click to edit Master title style
functions from the urllib Module
➢ There are certain functions from the urllib Module from Python 2.x that
are now part of the urllib.parse Library in the latest versions of Python. In
our Syllabus, we are covering 5 functions of the Legacy urllib Module:
➢ urllib.parse.quote() -> formerly urllib.quote()
➢ urllib.parse.quote_plus() -> formerly urllib.quote_plus()
➢ urllib.parse.unquote() -> formerly urllib.unquote()
➢ urllib.parse.unquote_plus() -> formerly urllib.unquote_plus()
➢ urllib.parse.urlencode() -> formerly urllib.urlencode()
1818
urllib.request Library
Click to edit Master title
[Formerly known as urllib] style
➢ Our Syllabus covers two functions available in the urllib.request Library:
➢ urllib.request.urlopen() -> formerly urllib.urlopen()
➢ urllib.request.urlretrieve() -> formerly urllib.urlretrieve()
2121
Click to edit Master title style
2222
Click to edit Master title style
Legacy Functions
of the ‘urllib’
Module that were
available in Python
2.x & Below
2323
Click to edit Master title style
Web Frameworks:
Web Clients &
Web Servers
CSE304 – Python Programming and Web Frameworks
Dr R Anushiadevi/SoC/SASTRA
Textbook: Wesley J Chun, Core PYTHON Applications Programming,
Prentice Hall, Third Edition, 2013
24
Web to
Click Clients in a Nutshell
edit Master title style
➢ One example of a well-known Web Client is the Crawler/Spider/Bot.
➢ This bot has been tasked to perform a variety of tasks that include:
➢ Indexing into a Large Search Engine such as Google, Yahoo!, etc;
➢ Offline Browsing – Downloading Documents onto a Local Hard Disk and
rearranging hyperlinks to create mirrors of files for local browsing;
➢ Downloading and storing historical or Archival Documents;
➢ Web Page Caching to save superfluous downloading time on Website revisits.
➢ How does it do that? It is a very long complex code that contains modules
like HTMLParser, cStringIO and the urllib with BeautifulSoup providing the
Graphical User Interface (GUI) for the Client.
➢ There are also Third-Party Web Browser Simulating Tools called
Mechanize which also runs on Python over the BeautifulSoup GUI Interface.
2525
Web to
Click Servers
edit Master title style
➢ Many Web Clients like Google Chrome, Mozilla Firefox, Brave Browser,
Microsoft Edge, Opera GX, Safari, etc… use dedicated Web Servers like
Apache, ligHTTPD, Microsoft IIS, LiteSpeed Technologies LiteSpeed, ACME
Laboratories thttpd to establish the Client-Server Architecture.
➢ Django and Google App Engine developmental Servers were based on the
‘BaseHTTPServer’ module of Python.
➢ The Handler is the piece of software that does the majority of Web Serving.
➢ It processes Client Requests, identifies the requested Information and
returns an appropriate response being either statically or dynamically
generated. The amount of requests a server can handle will approximately
give you the efficiency of the server.
➢ Once again, most of these modules have been deemed ‘Obsolete’ from
Python 3.x. However, similar behaving modules have efficiently replaced
them in the latest versions while also giving provisional legacy support.
2626
Web to
Click Servers in a Nutshell
edit Master title style
2727
Click to edit Master title style
Thank You!
28