0
0
Flaskframework~10 mins

Gunicorn for production serving in Flask - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import Gunicorn's WSGI server to run a Flask app.

Flask
from flask import Flask
app = Flask(__name__)

if __name__ == '__main__':
    from [1] import WSGIApplication
    http_server = WSGIApplication('__main__:app')
    http_server.cfg.set('bind', '0.0.0.0:8000')
    http_server.run()
Drag options to blanks, or click blank then click option'
Agunicorn.workers
Bgunicorn
Cgunicorn.app.wsgiapp
Dgunicorn.http
Attempts:
3 left
💡 Hint
Common Mistakes
Importing from 'gunicorn' directly instead of the correct submodule.
Using 'gunicorn.http' which is unrelated to WSGI server.
Trying to import from 'gunicorn.workers' which is for worker classes.
2fill in blank
medium

Complete the command to start a Flask app with Gunicorn on port 5000.

Flask
gunicorn -b 0.0.0.0:5000 [1]:app
Drag options to blanks, or click blank then click option'
Awsgi
Bmyapp
Capp
Dserver
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'app' as the module name when it's usually the variable name.
Using 'server' which is not the module name.
Forgetting to specify the module before ':app'.
3fill in blank
hard

Fix the error in the Gunicorn command to run with 4 worker processes.

Flask
gunicorn -w [1] myapp:app
Drag options to blanks, or click blank then click option'
Atwo
B4
Cfour
Dworker4
Attempts:
3 left
💡 Hint
Common Mistakes
Using words like 'four' instead of the number 4.
Using invalid strings like 'worker4'.
Using spelled-out numbers causing syntax errors.
4fill in blank
hard

Fill both blanks to create a Gunicorn command that binds to localhost on port 8080 and uses 2 workers.

Flask
gunicorn -w [2] -b 127.0.0.1:8080 [1]
Drag options to blanks, or click blank then click option'
Amyapp:app
Bapp:myapp
C2
D4
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping module and app names.
Using wrong number of workers.
Incorrect binding address format.
5fill in blank
hard

Fill all three blanks to create a Gunicorn command that runs 'server:app' with 3 workers and logs to 'gunicorn.log'.

Flask
gunicorn -w [2] --log-file [3] [1]
Drag options to blanks, or click blank then click option'
Aserver:app
B3
Cgunicorn.log
Dapp:server
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping module and app names.
Using wrong number of workers.
Forgetting to specify the log file.