|
@@ -1,36 +1,35 @@
|
1
|
1
|
import os
|
2
|
2
|
from flask import Flask
|
3
|
|
-
|
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
|
|
- )
|
10
|
|
-
|
11
|
|
- if test_config is None:
|
12
|
|
- app.config.from_pyfile('config.py', silent=True)
|
13
|
|
- else:
|
14
|
|
- app.config.from_mapping(test_config)
|
15
|
|
-
|
16
|
|
- try:
|
17
|
|
- os.makedirs(app.instance_path)
|
18
|
|
- except OSError:
|
19
|
|
- pass
|
20
|
|
-
|
21
|
|
- from . import db
|
22
|
|
- db.init_app(app)
|
23
|
|
-
|
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
|
|
- from . import admin_remove
|
33
|
|
- app.register_blueprint(admin_remove.bp)
|
34
|
|
- app.add_url_rule('/admin_remove', endpoint='admin_remove')
|
35
|
|
-
|
36
|
|
- return app
|
|
3
|
+from flask_mail import Mail
|
|
4
|
+
|
|
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)
|
|
16
|
+
|
|
17
|
+try:
|
|
18
|
+ os.makedirs(app.instance_path)
|
|
19
|
+except OSError:
|
|
20
|
+ pass
|
|
21
|
+
|
|
22
|
+from . import db
|
|
23
|
+db.init_app(app)
|
|
24
|
+
|
|
25
|
+from . import index
|
|
26
|
+app.register_blueprint(index.bp)
|
|
27
|
+app.add_url_rule('/', endpoint='index')
|
|
28
|
+
|
|
29
|
+from . import admin_insert
|
|
30
|
+app.register_blueprint(admin_insert.bp)
|
|
31
|
+app.add_url_rule('/admin_insert', endpoint='admin_insert')
|
|
32
|
+
|
|
33
|
+from . import admin_remove
|
|
34
|
+app.register_blueprint(admin_remove.bp)
|
|
35
|
+app.add_url_rule('/admin_remove', endpoint='admin_remove')
|