Skip to content

Latest commit

 

History

History
84 lines (63 loc) · 3.03 KB

Simple-dev-python-http-servers.md

File metadata and controls

84 lines (63 loc) · 3.03 KB

Simple python http server options for development [EARLY DRAFT].

Again, this is mostly a reminder for my own work.
One common use case is to quickly set up a web server to host your app at various stages of development.
 

Python 3 [in a pinch]


This is only a low-functioning, generally insecure server option...

python3 -m http.server -d ~/dev/myCurrentApplication/ 8080 --bind 127.0.0.1

 


Gunicorn is a Python WSGI HTTP Server for UNIX.

Install using pip

$ pip3 install gunicorn  

Start the app using gunicorn:

$ gunicorn --bind 0.0.0.0:8001 run:app  

Point your browser at http://localhost:8001.

 


Waitress (think Gunicorn for Windows), a production-quality pure-Python WSGI server. It has no dependencies outside the Python standard library.

Install using pip

$ pip3 install waitress  

Start the app using waitress-serve

$ waitress-serve --port=8001 run:app    

Point your browser at http://localhost:8001.

 


uWSGI, performant WSGI server implementation for UNIX.

Install using pip

Install the latest stable release:

$ pip3 install uwsgi   

Or install the latest LTS (long term support) release:

pip3 install https://projects.unbit.it/downloads/uwsgi-lts.tar.gz  

Start uWSGI to run an HTTP server/router passing requests to your Flask application:

uwsgi --http 127.0.0.1:8001 --wsgi-file myflaskapp.py --callable app  

Or start uWSGI to run an HTTP server/router passing requests to your native WSGI application:

$ uwsgi --http 127.0.0.1:8001 --wsgi-file helloworld.py  

Point your browser at http://localhost:8001.

uWSGI has lots of startup options to enhance performance and production readiness. See:

  The examples above assume Flask, but there are options: https://rapidapi.com/blog/best-python-api-frameworks/