SlideShare uma empresa Scribd logo
1 de 12
Python WSGI
Protocol
-Presented By
Rinkal Modi
Divya Ahuja
Krisha Jain
Outlines
 Why WSGI?
 Introduction
 What is WSGI?
 Middleware
 Requests and Responses
 Example
 Advantages
Why WSGI?
• WSGI servers are designed to handle many requests
concurrently.
• WSGI speeds up Python web application development because
you only need to know basic things about WSGI.
• WSGI gives you the flexibility of changing web stack components
for alternatives without changing the application that runs with
WSGI.
Introduction
• The Web Server Gateway Interface (WSGI) is a specification for
simple and universal interface between web servers and web
applications for the python.
• The WSGI has two sides:
1. server/gateway
2. Application/framework.
• To process a WSGI request, the server side executes the
application and provides environment information and a callback
function to the application side.
Continue…
• The application processes the request, returning the response to
the server side using the callback function.
• Between the server and application, there may be a WSGI
middleware, which implements both sides of API.
• The server receives a request from a client and forwards it to the
middleware.
• After processing, it sends a request to the application.
• The applications response is forwarded by the middleware to the
server and ultimately to the client.
What is WSGI?
• HTTP = Hyper Text Transfer Protocol
• WSGI = Web Server Gateway Interface
Middleware
• Middleware : A component that play both sides.
• A single object may play the role of server with respect to some
applications, while also acting as an application with respect to
some servers.
• Thus it is transparent to both the server/gateway and the
application/framework sides of interface.
Continue…
• FUNCTIONS :
i. Routing request to different applications based on target
URL.
ii. Allowing multiple applications/framework to run side by
side in same process.
iii. Load balancing and remote processing, by forwarding
requests and responses over a network.
iv. Perform content post processing, such as applying XSL style
sheets.
Requests and Responses
Example
#web_application.py
from wsgiref.simple_server import make_server
def application(environ, start_response):
path = environ.get('PATH_INFO')
if path == '/':
response_body = "Index"
else:
response_body = "Hello"
status = "200 OK"
response_headers = [("Content-Length", str(len(response_body)))]
start_response(status, response_headers)
return [response_body]
httpd = make_server(
'127.0.0.1', 8051, application)
httpd.serve_forever()
Advantages
• Applications can be run by different users.
• No need to restart the web server to upgrade code.
• Applications with different versions of python.
• No shared libraries conflicts.
Thank You..

Mais conteúdo relacionado

Mais procurados

Single page application
Single page applicationSingle page application
Single page applicationJeremy Lee
 
Владимир Логвинов - Rest-Assured - легкий способ автоматизации тестирования REST
Владимир Логвинов - Rest-Assured - легкий способ автоматизации тестирования RESTВладимир Логвинов - Rest-Assured - легкий способ автоматизации тестирования REST
Владимир Логвинов - Rest-Assured - легкий способ автоматизации тестирования RESTWeb Tech Fun
 
Understanding SOAP and REST basics and differences
Understanding SOAP and REST basics and differencesUnderstanding SOAP and REST basics and differences
Understanding SOAP and REST basics and differencesBhavendra Chavan
 
Soap vs. rest - which is right web service protocol for your need?
Soap vs. rest -  which is right web service protocol for your need?Soap vs. rest -  which is right web service protocol for your need?
Soap vs. rest - which is right web service protocol for your need?Vijay Prasad Gupta
 
(ATS6-DEV03) Building an Enterprise Web Solution with AEP
(ATS6-DEV03) Building an Enterprise Web Solution with AEP(ATS6-DEV03) Building an Enterprise Web Solution with AEP
(ATS6-DEV03) Building an Enterprise Web Solution with AEPBIOVIA
 
Soa 30 jax ws client side development
Soa 30 jax ws client side developmentSoa 30 jax ws client side development
Soa 30 jax ws client side developmentVaibhav Khanna
 
Signalr with ASP.Net part2
Signalr with ASP.Net part2Signalr with ASP.Net part2
Signalr with ASP.Net part2Esraa Ammar
 
Single page applications with backbone js
Single page applications with backbone jsSingle page applications with backbone js
Single page applications with backbone jsGil Fink
 
An Overview of Web Services: SOAP and REST
An Overview of Web Services: SOAP and REST An Overview of Web Services: SOAP and REST
An Overview of Web Services: SOAP and REST Ram Awadh Prasad, PMP
 
WSDL in Mule Esb
WSDL in Mule EsbWSDL in Mule Esb
WSDL in Mule EsbAnand kalla
 
Using MVC with Kentico 8
Using MVC with Kentico 8Using MVC with Kentico 8
Using MVC with Kentico 8Thomas Robbins
 
Server-Sent Events in Action
Server-Sent Events in ActionServer-Sent Events in Action
Server-Sent Events in ActionAndrei Rusu
 

Mais procurados (20)

Single page application
Single page applicationSingle page application
Single page application
 
zigbee
zigbeezigbee
zigbee
 
Single page application
Single page applicationSingle page application
Single page application
 
Владимир Логвинов - Rest-Assured - легкий способ автоматизации тестирования REST
Владимир Логвинов - Rest-Assured - легкий способ автоматизации тестирования RESTВладимир Логвинов - Rest-Assured - легкий способ автоматизации тестирования REST
Владимир Логвинов - Rest-Assured - легкий способ автоматизации тестирования REST
 
Understanding SOAP and REST basics and differences
Understanding SOAP and REST basics and differencesUnderstanding SOAP and REST basics and differences
Understanding SOAP and REST basics and differences
 
Soap vs. rest - which is right web service protocol for your need?
Soap vs. rest -  which is right web service protocol for your need?Soap vs. rest -  which is right web service protocol for your need?
Soap vs. rest - which is right web service protocol for your need?
 
(ATS6-DEV03) Building an Enterprise Web Solution with AEP
(ATS6-DEV03) Building an Enterprise Web Solution with AEP(ATS6-DEV03) Building an Enterprise Web Solution with AEP
(ATS6-DEV03) Building an Enterprise Web Solution with AEP
 
Soa 30 jax ws client side development
Soa 30 jax ws client side developmentSoa 30 jax ws client side development
Soa 30 jax ws client side development
 
Kentico and MVC
Kentico and MVCKentico and MVC
Kentico and MVC
 
Testing microservices with rest assured
Testing microservices with rest assuredTesting microservices with rest assured
Testing microservices with rest assured
 
SOAP vs REST
SOAP vs RESTSOAP vs REST
SOAP vs REST
 
Overview of java web services
Overview of java web servicesOverview of java web services
Overview of java web services
 
Signalr with ASP.Net part2
Signalr with ASP.Net part2Signalr with ASP.Net part2
Signalr with ASP.Net part2
 
Single page applications with backbone js
Single page applications with backbone jsSingle page applications with backbone js
Single page applications with backbone js
 
An Overview of Web Services: SOAP and REST
An Overview of Web Services: SOAP and REST An Overview of Web Services: SOAP and REST
An Overview of Web Services: SOAP and REST
 
WSDL in Mule Esb
WSDL in Mule EsbWSDL in Mule Esb
WSDL in Mule Esb
 
Using MVC with Kentico 8
Using MVC with Kentico 8Using MVC with Kentico 8
Using MVC with Kentico 8
 
Web Services
Web Services  Web Services
Web Services
 
Server-Sent Events in Action
Server-Sent Events in ActionServer-Sent Events in Action
Server-Sent Events in Action
 
Web Services in the Real World
Web Services in the Real WorldWeb Services in the Real World
Web Services in the Real World
 

Semelhante a Python wsgi protocol

IT2255 Web Essentials - Unit V Servlets and Database Connectivity
IT2255 Web Essentials - Unit V Servlets and Database ConnectivityIT2255 Web Essentials - Unit V Servlets and Database Connectivity
IT2255 Web Essentials - Unit V Servlets and Database Connectivitypkaviya
 
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1...
 Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1... Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1...
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1...WebStackAcademy
 
Server side programming
Server side programming Server side programming
Server side programming javed ahmed
 
Build Modern Web Apps Using ASP.NET Web API and AngularJS
Build Modern Web Apps Using ASP.NET Web API and AngularJSBuild Modern Web Apps Using ASP.NET Web API and AngularJS
Build Modern Web Apps Using ASP.NET Web API and AngularJSTaiseer Joudeh
 
Advancio, Inc. Academy: Web Sevices, WCF & SOAPUI
Advancio, Inc. Academy: Web Sevices, WCF & SOAPUIAdvancio, Inc. Academy: Web Sevices, WCF & SOAPUI
Advancio, Inc. Academy: Web Sevices, WCF & SOAPUIAdvancio
 
web services-May 25.ppt
web services-May 25.pptweb services-May 25.ppt
web services-May 25.pptShivaangiKrish
 
Displaying google maps in mobileapplication.pptx
Displaying google maps in mobileapplication.pptxDisplaying google maps in mobileapplication.pptx
Displaying google maps in mobileapplication.pptxsanaiftikhar23
 
Intorduction to struts
Intorduction to strutsIntorduction to struts
Intorduction to strutsAnup72
 
Web services - A Practical Approach
Web services - A Practical ApproachWeb services - A Practical Approach
Web services - A Practical ApproachMadhaiyan Muthu
 
15.web document types.pdf bdgjrjdhdhsgbdidh
15.web document types.pdf bdgjrjdhdhsgbdidh15.web document types.pdf bdgjrjdhdhsgbdidh
15.web document types.pdf bdgjrjdhdhsgbdidhKomaliGuptha1
 
Web Clients for Ruby and What they should be in the future
Web Clients for Ruby and What they should be in the futureWeb Clients for Ruby and What they should be in the future
Web Clients for Ruby and What they should be in the futureToru Kawamura
 
Anintroductiontojavawebtechnology 090324184240-phpapp01
Anintroductiontojavawebtechnology 090324184240-phpapp01Anintroductiontojavawebtechnology 090324184240-phpapp01
Anintroductiontojavawebtechnology 090324184240-phpapp01raviIITRoorkee
 
IoT Physical Servers and Cloud Offerings.pdf
IoT Physical Servers and Cloud Offerings.pdfIoT Physical Servers and Cloud Offerings.pdf
IoT Physical Servers and Cloud Offerings.pdfGVNSK Sravya
 
WEB TECHNOLOGY Unit-3.pptx
WEB TECHNOLOGY Unit-3.pptxWEB TECHNOLOGY Unit-3.pptx
WEB TECHNOLOGY Unit-3.pptxkarthiksmart21
 
Ppt for Online music store
Ppt for Online music storePpt for Online music store
Ppt for Online music storeADEEBANADEEM
 
Azure Web App services
Azure Web App servicesAzure Web App services
Azure Web App servicesAlexey Bokov
 

Semelhante a Python wsgi protocol (20)

IT2255 Web Essentials - Unit V Servlets and Database Connectivity
IT2255 Web Essentials - Unit V Servlets and Database ConnectivityIT2255 Web Essentials - Unit V Servlets and Database Connectivity
IT2255 Web Essentials - Unit V Servlets and Database Connectivity
 
Wt unit 6 ppts web services
Wt unit 6 ppts web servicesWt unit 6 ppts web services
Wt unit 6 ppts web services
 
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1...
 Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1... Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1...
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1...
 
Server side programming
Server side programming Server side programming
Server side programming
 
Build Modern Web Apps Using ASP.NET Web API and AngularJS
Build Modern Web Apps Using ASP.NET Web API and AngularJSBuild Modern Web Apps Using ASP.NET Web API and AngularJS
Build Modern Web Apps Using ASP.NET Web API and AngularJS
 
Ecom 1
Ecom 1Ecom 1
Ecom 1
 
CS-802 Act-1.ppt
CS-802 Act-1.pptCS-802 Act-1.ppt
CS-802 Act-1.ppt
 
Advancio, Inc. Academy: Web Sevices, WCF & SOAPUI
Advancio, Inc. Academy: Web Sevices, WCF & SOAPUIAdvancio, Inc. Academy: Web Sevices, WCF & SOAPUI
Advancio, Inc. Academy: Web Sevices, WCF & SOAPUI
 
web services-May 25.ppt
web services-May 25.pptweb services-May 25.ppt
web services-May 25.ppt
 
Displaying google maps in mobileapplication.pptx
Displaying google maps in mobileapplication.pptxDisplaying google maps in mobileapplication.pptx
Displaying google maps in mobileapplication.pptx
 
Intorduction to struts
Intorduction to strutsIntorduction to struts
Intorduction to struts
 
Web services - A Practical Approach
Web services - A Practical ApproachWeb services - A Practical Approach
Web services - A Practical Approach
 
15.web document types.pdf bdgjrjdhdhsgbdidh
15.web document types.pdf bdgjrjdhdhsgbdidh15.web document types.pdf bdgjrjdhdhsgbdidh
15.web document types.pdf bdgjrjdhdhsgbdidh
 
Web Clients for Ruby and What they should be in the future
Web Clients for Ruby and What they should be in the futureWeb Clients for Ruby and What they should be in the future
Web Clients for Ruby and What they should be in the future
 
Anintroductiontojavawebtechnology 090324184240-phpapp01
Anintroductiontojavawebtechnology 090324184240-phpapp01Anintroductiontojavawebtechnology 090324184240-phpapp01
Anintroductiontojavawebtechnology 090324184240-phpapp01
 
IoT Physical Servers and Cloud Offerings.pdf
IoT Physical Servers and Cloud Offerings.pdfIoT Physical Servers and Cloud Offerings.pdf
IoT Physical Servers and Cloud Offerings.pdf
 
WEB TECHNOLOGY Unit-3.pptx
WEB TECHNOLOGY Unit-3.pptxWEB TECHNOLOGY Unit-3.pptx
WEB TECHNOLOGY Unit-3.pptx
 
Top java script frameworks ppt
Top java script frameworks pptTop java script frameworks ppt
Top java script frameworks ppt
 
Ppt for Online music store
Ppt for Online music storePpt for Online music store
Ppt for Online music store
 
Azure Web App services
Azure Web App servicesAzure Web App services
Azure Web App services
 

Último

Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...anjaliyadav012327
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...Pooja Nehwal
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 

Último (20)

Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 

Python wsgi protocol

  • 1. Python WSGI Protocol -Presented By Rinkal Modi Divya Ahuja Krisha Jain
  • 2. Outlines  Why WSGI?  Introduction  What is WSGI?  Middleware  Requests and Responses  Example  Advantages
  • 3. Why WSGI? • WSGI servers are designed to handle many requests concurrently. • WSGI speeds up Python web application development because you only need to know basic things about WSGI. • WSGI gives you the flexibility of changing web stack components for alternatives without changing the application that runs with WSGI.
  • 4. Introduction • The Web Server Gateway Interface (WSGI) is a specification for simple and universal interface between web servers and web applications for the python. • The WSGI has two sides: 1. server/gateway 2. Application/framework. • To process a WSGI request, the server side executes the application and provides environment information and a callback function to the application side.
  • 5. Continue… • The application processes the request, returning the response to the server side using the callback function. • Between the server and application, there may be a WSGI middleware, which implements both sides of API. • The server receives a request from a client and forwards it to the middleware. • After processing, it sends a request to the application. • The applications response is forwarded by the middleware to the server and ultimately to the client.
  • 6. What is WSGI? • HTTP = Hyper Text Transfer Protocol • WSGI = Web Server Gateway Interface
  • 7. Middleware • Middleware : A component that play both sides. • A single object may play the role of server with respect to some applications, while also acting as an application with respect to some servers. • Thus it is transparent to both the server/gateway and the application/framework sides of interface.
  • 8. Continue… • FUNCTIONS : i. Routing request to different applications based on target URL. ii. Allowing multiple applications/framework to run side by side in same process. iii. Load balancing and remote processing, by forwarding requests and responses over a network. iv. Perform content post processing, such as applying XSL style sheets.
  • 10. Example #web_application.py from wsgiref.simple_server import make_server def application(environ, start_response): path = environ.get('PATH_INFO') if path == '/': response_body = "Index" else: response_body = "Hello" status = "200 OK" response_headers = [("Content-Length", str(len(response_body)))] start_response(status, response_headers) return [response_body] httpd = make_server( '127.0.0.1', 8051, application) httpd.serve_forever()
  • 11. Advantages • Applications can be run by different users. • No need to restart the web server to upgrade code. • Applications with different versions of python. • No shared libraries conflicts.