October 2018
Intermediate to advanced
332 pages
8h 9m
English
Flask is very powerful, but will most definitely not get in your way. You can use it to create a simple web application using a single file. Our aim is to create a project that is structured in a way that it can scale and be easy to understand. For now, we will create a config file first. 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 ...