Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
WSGI server vs Web Server
#1
Hello everyone,

I've been trying to get into the concept of wsgi, but I still got some questions:

- from wat I can tell most wsgi servers are also http servers?
- can I run a wsgi server, without using a web server to run a webapp (i.e. run an angular spa with a rest api in flask with waitress alone)?
- what are the advantages of using a web server in combination with a wsgi server

thank you
Reply
#2
can I run a wsgi server, without using a web server to run a webapp:

Yes, you can.
Reply
#3
i am doing my web stuff "in the cloud" ... specifically at AWS. S3 is, effectively, i nice low cost web server. but, it's static, and has to be front-ended to do HTTPS. i had to split things between a static server and a dynamic server. so, my domains have multiple host names, some going to S3, some going to a server running in an instance, both using CloudFront for caching. there are names like www.example.com, images.example.com, submit.example.com, downloads.example.com.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#4
What does your server cost at maximum (runs 24h, 30 day)?
Reply
#5
i'd have to work it out. i do other stuff there, too, like various backups, multiple domains, cloud automation testing, stuff for one of my clients. even then, i'm often under $10 total, per month, not counting some domain registration i have, there.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#6
Thank you.
Reply
#7
(Apr-24-2019, 07:43 AM)chrisdb Wrote: - can I run a wsgi server, without using a web server to run a webapp (i.e. run an angular spa with a rest api in flask with waitress alone)?
The work flow with eg Flask is building the web-app is all done local with Development Server(wsgi) that come with Flask.
If want to share with the world then get a host and then leave development server and then eg go for good option like Gunicorn and Nginx.
Look at this post for host recommendations.

WSGI Servers for a little history.
As a note there no need to dig into WSGI specification,unless you want build yet another Python web-framework.
fullstackpython Wrote:WSGI is by design a simple standard interface for running Python code.
As a web developer you won't need to know much more than
  • what WSGI stands for (Web Server Gateway Inteface)

  • that a WSGI container is a separate running process that runs on a different port than your web server

  • that a WSGI container is a separate running process that runs on a different port than your web server
    your web server is configured to pass requests to the WSGI container which runs your web application,
    then pass the response (in the form of HTML) back to the requester
Reply
#8
why can't you just set up the wsgi container to listen to ports 80/443 directly and reduce the total workload on your server and increase the response time?

and i have already written my own little http server and am curious how much work would be involved to add wsgi support to it (not as the proxy).

edit:

that little http server i wrote is entirely in python. i wrote it back before i did anything with python3 (which is now the only python version i write for) and i have not updated it, yet. so i guess that means it is currently a python2 thing. its design is to use the http request path to find a python file and it loads it as a module and runs it in the same process. it is not a multi-user server.

edit:

the apache server and many others support the cgi method of dynamic execution. to execute python code, the code will have to be a command which runs in a separate process which exits when complete, making for a lower performing server. this includes the disadvantage of the need to store persistent data in files (and probably deal with process sharing issues) or in a database that a new connection needs to be made to for each dynamic web request.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#9
Quote:why can't you just set up the wsgi container to listen to ports 80/443 directly and reduce the total workload on your server and increase the response time?

and i have already written my own little http server and am curious how much work would be involved to add wsgi support to it (not as the proxy).
Yes can do other stuff,i also have written toy web-server as practice.
But when i advice what people should use i mention Gunicorn which is a production ready fast WSGI HTTP Server.
With NGIX(not Apache in my option) in front for Proxy Requests.

I also mention AWS in link i posted,for not messing with server stuff talked about over at all.
Can re-post it here:
Not messing with server setup AWS Lambda
AWS Lambda Wrote:AWS Lambda lets you run code without provisioning or managing servers.
You pay only for the compute time you consume - there is no charge when your code is not running.
For Python setup is Zappa good.
zappa Wrote:Never Worry About Web Hosting Again


(May-27-2019, 12:32 AM)Skaperen Wrote: the apache server and many others support the cgi method of dynamic execution.
Apache will i not use when Nginx is a better and easier to use in my option,CGI is dead in Python it will be removed in the future PEP 594.
CGI was never a good solution for Python in the future,that's why Python community did write an all Python solution PEP 3333(WSGI).
Reply
#10
For CGI: see https://python-forum.io/Thread-Run-Pytho...rom-Apache


For Flask: see https://python-forum.io/Thread-Flask-Sta...ent-part-1
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  python packaging/ hosted in IIS server manjureka 0 151 Apr-16-2024, 10:43 AM
Last Post: manjureka
  Script does not work on Linux server scrapemasta 0 246 Mar-22-2024, 11:07 AM
Last Post: scrapemasta
  Using a Proxy Server rsherry8 12 24,885 Dec-04-2023, 06:35 PM
Last Post: AlluminumFoil
  Server Error with parse_args() using Flask NoNameoN 0 1,097 Jul-30-2022, 09:42 AM
Last Post: NoNameoN
  [split] flask 500 internal server error DarthTensor 3 4,028 Nov-11-2021, 06:10 AM
Last Post: DarthTensor
  deploying python script on a server rickyrt 0 1,473 Aug-31-2021, 04:03 PM
Last Post: rickyrt
Question Flask, Self-hosted deployment, which server ? SpongeB0B 1 3,036 Apr-11-2021, 11:29 AM
Last Post: snippsat
  Connecting to a web server with authentification arbiel 0 1,595 Feb-02-2021, 08:31 PM
Last Post: arbiel
Question Telegram bot - Problem with proxies and web server NoNameoN 1 3,137 Oct-16-2020, 05:37 PM
Last Post: NoNameoN
  how to run a Python programm on a web server? gtlhbkkj 2 1,977 Aug-10-2020, 12:44 PM
Last Post: abusalim

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020