A simple Flask application with routing and Jinja templates. Accompanying slides can be found here. Workshop held by the NYU Girls Who Code College Loop Chapter! To reach out with any general questions, please email nyugwc@gmail.com
If you want to start this project from scratch ...
Make sure you have Python downloaded on your device, download it here. It should be Python version 2.7 or newer.
If you do not have pip already installed on your computer, follow this tutorial to install pip. (pip3 should work aswell)
pip install virtualenv
$ mkdir flask-project
$ cd flask-project
$ python3 -m venv env # for python3, MacOS, Linux
$ python -m virtualenv env # for python2, MacOS, Linux
$ py -3 -m venv env # for python3, Windows
$ py -2 -m virtualenv env # for python2, Windows
$ source env/bin/activate # activate env on MacOS, Linux
$ env\Scripts\activate # activate env on Windows
$ touch app.py .gitignore README.md requirements.txt
$ pip install Flask
$ python -m pip freeze > requirements.txt
In your main.py:
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello world!'
$ export FLASK_APP=run.py # Unix/Mac)
$ set FLASK_APP=run.py # Windows
$ env:FLASK_APP = ".\run.py" # Powershell
$ export FLASK_ENV=development
flask run
Then navigate to the localhost the site is running on.
deactivate
If you prefer to use this repository...
$ git clone https://github.com/rachelombok/Flask-Workshop-GWC.git
$ cd flask-workshop-gwc
$ pip install -r requirements.txt
... and follow the previous steps for setting up the environment, and running.
Use this file for your .gitignore