Skip to Content
Mastering Flask
book

Mastering Flask

by Jack Stouffer
September 2015
Intermediate to advanced
288 pages
5h 30m
English
Packt Publishing
Content preview from Mastering Flask

The beginning of our project

Finally, we can get to our first Flask project. In order to have a complex project at the end of the book, we will need a simple Flask project to start us off.

In the file named config.py, add the following:

class Config(object):
    pass

class ProdConfig(Config):
    pass

class DevConfig(Config):
    DEBUG = True

Now, in another file named main.py, add the following:

from flask import Flask
from config import DevConfig

app = Flask(__name__)
app.config.from_object(DevConfig)

@app.route('/')
def home():
    return '<h1>Hello World!</h1>'

if __name__ == '__main__':
    app.run()

For anyone who is familiar with the base Flask API, this program is very basic. It will just show Hello World! on the browser if we navigate to http://127.0.0.1:5000/ ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

An Introduction to Flask

An Introduction to Flask

Miguel Grinberg
Flask Blueprints

Flask Blueprints

Joel Perras
Flask By Example

Flask By Example

Gareth Dwyer

Publisher Resources

ISBN: 9781784393656Supplemental Content