jonnyhuck / flask-examples

Some minimal Flask examples for my students

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Minimal Flask Examples

This repository contains a set of examples for how to use a Flask Python Server, intended to provide simple illustrations of how to integrate flask with other technologies for my students.

Each directory is a separate Flask Server instance, and should be run using the following command:

Running Flask

Inside each directory, you can run Flask by typing the following commands into the terminal / command line:

Mac / Linux etc:

export FLASK_APP=hello
export FLASK_ENV=development
flask run

(or, in a single line...)

export FLASK_APP=hello && export FLASK_ENV=development && flask run

Windows:

set FLASK_APP=hello
set FLASK_ENV=development
flask run

In all cases, if it has worked, you should get the following response:

 * 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 http://127.0.0.1:5000 (Press CTRL+C to quit)

Once this happens, you should be able to find your server by typing http://127.0.0.1:5000 into your web browser (or clicking the link).

In each example directory, the server code is in hello.py and the HTML (web page) is stored in templates.

More information on the basics of running Flask can be found in the Flask documentation here.

About

Some minimal Flask examples for my students

License:GNU General Public License v3.0


Languages

Language:HTML 52.5%Language:Python 47.5%