- Python framework used to build web applications
- Easy to extend core functionality (Flask-SQLAlchemy for example)
- Run
pipenv install && pipenv shell
- Import flask, in
server/app.py
:
from flask import Flask
- Create an instance of the
Flask
class, namedapp
:
# server/app.py
from flask import Flask
app = Flask(__name__)
- Configure
app.py
to run as a script, and set debug mode to True which will allow us to see our changes without restarting the server:
from flask import Flask
app = Flask(__name__)
# Routes here
if __name__ == '__main__':
app.run(port=5555, debug=True)
-
Create some routes
-
Run the app one of two ways:
python server/app.py
to run it as a script (with debug mode)flask run
to run it through flask - if you go this route make sure to configure the environment variables:export FLASK_APP=app.py export FLASK_RUN_PORT=5555 cd server flask run