0
0
Flaskframework~5 mins

WSGI servers (Gunicorn, uWSGI) in Flask - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does WSGI stand for and why is it important in Python web development?
WSGI stands for Web Server Gateway Interface. It is a standard interface between web servers and Python web applications or frameworks. It allows web servers to communicate with Python code in a consistent way.
Click to reveal answer
beginner
What is Gunicorn and what role does it play when deploying a Flask app?
Gunicorn is a WSGI HTTP server for Python. It runs your Flask app and handles multiple requests by managing worker processes, making your app ready to serve many users efficiently.
Click to reveal answer
intermediate
How does uWSGI differ from Gunicorn in serving Flask applications?
uWSGI is another WSGI server that supports more protocols and features than Gunicorn. It is highly configurable and can serve Python apps but also supports other languages. Gunicorn is simpler and focused on Python WSGI apps.
Click to reveal answer
beginner
Why should you not use Flask's built-in server in production?
Flask's built-in server is meant for development only. It is single-threaded and not designed to handle many users or heavy traffic. WSGI servers like Gunicorn or uWSGI are made for production and can handle multiple requests safely.
Click to reveal answer
intermediate
What is a worker process in the context of Gunicorn or uWSGI?
A worker process is a separate process that handles incoming web requests. Multiple workers allow your app to handle many users at the same time by running requests in parallel.
Click to reveal answer
What is the main purpose of a WSGI server like Gunicorn?
ATo serve static files only
BTo replace the Flask framework
CTo manage databases
DTo run Python web applications and handle multiple requests
Which of these is NOT a reason to use uWSGI over Flask's built-in server?
ASimpler to set up than Flask's built-in server
BBetter handling of multiple requests
CSupports multiple languages and protocols
DMore configurable for production use
What happens if you run a Flask app with its built-in server in production?
AIt will handle heavy traffic efficiently
BIt may crash or slow down under many users
CIt automatically switches to Gunicorn
DIt becomes a WSGI server
In Gunicorn, what is the role of worker processes?
ATo handle incoming web requests concurrently
BTo manage database connections
CTo update the Flask code automatically
DTo serve static images
Which command would you use to start a Flask app with Gunicorn?
Auwsgi --http :5000 --module app:app
Bflask run
Cgunicorn app:app
Dpython app.py
Explain what a WSGI server is and why it is needed when deploying a Flask application.
Think about how web servers talk to Python apps.
You got /4 concepts.
    Compare Gunicorn and uWSGI in terms of features and typical use cases for Flask apps.
    Consider ease of use versus configurability.
    You got /4 concepts.