How to Setup a New Flask App on a Local Windows Machine

Another quick little blog post here for my own future reference. I’m just getting started learning Flask and it’s quite different from doing web development in PHP like I’m used to. So here are a few quick steps to get started (assumes virtualenv and python 3 have already been installed):

Create a Blank Flask App

$ cd Desktop
$ mkdir my_new_flask_app
$ cd my_new_flask_app
$ virtualenv venv
$ venv\Scripts\activate
(venv) $ pip install flask

Hello, World (helloflask.py)

from flask import Flask
app = Flask(__name__)
@app.route('/')
def index():
    return 'hello, world'

Start Local Development Server

$ set FLASK_APP=helloflask.py
$ flask run

Visit Your New App With Your Web Browser: http://localhost:5000

 

topherPedersen