-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
53 lines (38 loc) · 1.15 KB
/
Copy pathconfig.py
File metadata and controls
53 lines (38 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
from flask import render_template
# Custom error pages
def page_not_found(e):
return render_template("error/404.html"), 404
def internal_server_error(e):
return render_template("error/500.html"), 500
class Production:
DEBUG = False
TESTING = False
ENV = "production"
# This will be overwritten by the values in
# instance/config.py
SECRET_KEY = "production_secret_key"
@staticmethod
def init_app(app):
# flask-quickstart/instance/config.py
app.config.from_pyfile("config.py", silent=True)
app.register_error_handler(404, page_not_found)
app.register_error_handler(500, internal_server_error)
return
class Development:
DEBUG = True
TESTING = False
ENV = "development"
SECRET_KEY = "development_secret_key"
@staticmethod
def init_app(app):
app.register_error_handler(404, page_not_found)
return
class Testing:
DEBUG = False
TESTING = True
ENV = "testing"
SECRET_KEY = "testing_secret_key"
@staticmethod
def init_app(app):
pass
config = {"production": Production, "development": Development, "testing": Testing}