Flask is a lightweight web application framework written in Python and based on the Werkzeug WSGI toolkit and Jinja2 template engine. It is BSD licensed.

Flask is called a microframework because it keeps the core simple but extensible. There is no database abstraction layer, form validation, or any other components where third-party libraries already exist to provide common functionality. However, Flask supports extensions, which can add such functionality into an application as if it was implemented in Flask itself. There are extensions for object-relational mappers, form validation, upload handling, various open authentication technologies, and more.


This tutorial will show you how to run Flask in CSE's server environment.

  1. Login to the student web development server, cheshire. Only cheshire is configured to run Flask.
    % ssh cheshire
  2. If you haven't already created your personal CSE web environment yet, follow this tutorial to set it up:
  3. Following the install-flask routine, install Flask. Within your public_html directory, create a directory called myproject. Change directory to myproject. Install the Flask virtual environment (venv).
    [cheshire] ~/public_html% mkdir myproject
    [cheshire] ~/public_html% cd myproject
    [cheshire] myproject% python3 -m venv venv
  5. To activate your virtual environment, you'll need to run the bash shell. Change your current shell to bash. CSE sets your default shell to tcsh. But you'll need to use bash for this job.
    [cheshire] myproject% bash
  6. Activate your Flask virtual environment (venv):
    bash-4.2$ . venv/bin/activate
  7. Within the activated environment, use the following command to install Flask:
    (venv) bash-4.2$ pip install Flask
  8. Following the a-minimal-application routine, create a file called hello.py in your myproject directory:
    (venv) bash-4.2$ vi hello.py
  9. Now run the application in development mode (when running flask run, optionally set the specific runtime port with the -p flag):
    $ export FLASK_APP=hello
    $ flask run --host= -p 5001
     * Serving Flask app 'hello' (lazy loading)
     * Environment: production
       WARNING: This is a development server. Do not use it in a production deployment.
       Use a production WSGI server instead.
     * Debug mode: off
     * Running on all addresses.
       WARNING: This is a development server. Do not use it in a production deployment.
     * Running on (Press CTRL+C to quit)
  10. Access your app from the web:


Consult cheshire's httpd error log:

[cheshire] ~% tail -f /var/log/httpd/httpd-error_log


  1. https://en.wikipedia.org/wiki/Flask_%28programming%29
  2. https://flask.pocoo.org/
  3. https://flask.palletsprojects.com/en/2.0.x/installation/#install-flask
  4. https://flask.palletsprojects.com/en/2.0.x/quickstart/#a-minimal-applica...