September 2015
Intermediate to advanced
288 pages
5h 30m
English
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 = TrueNow, 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/ ...