· 5 years ago · Feb 04, 2020, 08:58 AM
1-----app.py------
2from flask import Flask, render_template
3from flask_bootstrap import Bootstrap
4
5
6app = Flask(__name__)
7app.config.from_object('config.ProductionConfig')
8Bootstrap(app)
9
10
11@app.route('/')
12def hello_world():
13 return render_template('index.html')
14
15
16@app.errorhandler(404)
17def page_not_found(e):
18 # note that we set the 404 status explicitly
19 return render_template('404.html'), 404
20
21
22----wsgi.py------
23from app import app
24
25if __name__ == '__main__':
26 app.run()
27
28
29
30-----Config.py------
31import os
32basedir = os.path.abspath(os.path.dirname(__file__))
33
34
35class Config(object):
36 DEBUG = False
37 TESTING = False
38 CSRF_ENABLED = True
39 SECRET_KEY = 'my secret key'
40
41
42class ProductionConfig(Config):
43 DEBUG = False
44 FLASK_ENV = 'production'
45
46
47class StagingConfig(Config):
48 DEVELOPMENT = True
49 DEBUG = True
50
51
52class DevelopmentConfig(Config):
53 DEVELOPMENT = True
54 DEBUG = True
55
56
57class TestingConfig(Config):
58 TESTING = True