January 2018
Intermediate to advanced
366 pages
9h 7m
English
The app.py file is responsible for an instance of Flask. Just like any Python file, we will start by importing the dependencies. Soon after, we have the declaration of the instance of Flask, the access settings, the statement of routes, and the command to run the server:
import os
from flask import Flask
from views import news
# instantiate the app
app = Flask(__name__)
# set config
app_settings = os.getenv('APP_SETTINGS')
app.config.from_object(app_settings)
# register blueprints
app.register_blueprint(news)
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000)
Read now
Unlock full access