|
@@ -1,32 +1,31 @@
|
1
|
1
|
import os
|
2
|
2
|
from flask import Flask
|
|
3
|
+from flask_mail import Mail
|
3
|
4
|
|
4
|
|
-def create_app(test_config=None):
|
5
|
|
- app = Flask(__name__, instance_relative_config=True)
|
6
|
|
- app.config.from_mapping(
|
7
|
|
- SECRET_KEY='dev',
|
8
|
|
- DATABASE=os.path.join(app.instance_path, 'upr_espera.sqlite'),
|
9
|
|
- )
|
|
5
|
+app = Flask(__name__, instance_relative_config=True)
|
|
6
|
+app.config.from_mapping(
|
|
7
|
+ SECRET_KEY=os.environ.get('SECRET_KEY'),
|
|
8
|
+ DATABASE=os.path.join(app.instance_path, 'upr_espera.sqlite'),
|
|
9
|
+ MAIL_SERVER='smtp.googlemail.com',
|
|
10
|
+ MAIL_PORT=587,
|
|
11
|
+ MAIL_USE_TLS=1,
|
|
12
|
+ MAIL_USERNAME=os.environ.get('MAIL_USERNAME'),
|
|
13
|
+ MAIL_PASSWORD=os.environ.get('MAIL_PASSWORD'),
|
|
14
|
+)
|
|
15
|
+mail = Mail(app)
|
10
|
16
|
|
11
|
|
- if test_config is None:
|
12
|
|
- app.config.from_pyfile('config.py', silent=True)
|
13
|
|
- else:
|
14
|
|
- app.config.from_mapping(test_config)
|
|
17
|
+try:
|
|
18
|
+ os.makedirs(app.instance_path)
|
|
19
|
+except OSError:
|
|
20
|
+ pass
|
15
|
21
|
|
16
|
|
- try:
|
17
|
|
- os.makedirs(app.instance_path)
|
18
|
|
- except OSError:
|
19
|
|
- pass
|
|
22
|
+from . import db
|
|
23
|
+db.init_app(app)
|
20
|
24
|
|
21
|
|
- from . import db
|
22
|
|
- db.init_app(app)
|
|
25
|
+from . import index
|
|
26
|
+app.register_blueprint(index.bp)
|
|
27
|
+app.add_url_rule('/', endpoint='index')
|
23
|
28
|
|
24
|
|
- from . import index
|
25
|
|
- app.register_blueprint(index.bp)
|
26
|
|
- app.add_url_rule('/', endpoint='index')
|
27
|
|
-
|
28
|
|
- from . import admin_insert
|
29
|
|
- app.register_blueprint(admin_insert.bp)
|
30
|
|
- app.add_url_rule('/admin_insert', endpoint='admin_insert')
|
31
|
|
-
|
32
|
|
- return app
|
|
29
|
+from . import admin_insert
|
|
30
|
+app.register_blueprint(admin_insert.bp)
|
|
31
|
+app.add_url_rule('/admin_insert', endpoint='admin_insert')
|