-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
41 lines (28 loc) · 880 Bytes
/
app.py
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
from dotenv import load_dotenv
from flask import Flask
from marshmallow import ValidationError
from auth.auth_app import auth_app
from core.exceptions.base_error import BaseError
from extentions import db, migrate, marshmallow, mail
load_dotenv('.env')
app = Flask(__name__, template_folder='templates')
app.config.from_object('config.default')
app.config.from_envvar('CONFIGURATION_FILE')
app.register_blueprint(auth_app, url_prefix='/auth')
with app.test_request_context():
db.init_app(app)
db.create_all()
migrate.init_app(app, db)
marshmallow.init_app(app)
mail.init_app(app)
@app.errorhandler(ValidationError)
def validation_error(e):
return e.messages
@app.errorhandler(BaseError)
def app_error_handler(e):
return e.json(), e.code
@app.route('/')
def hello_world():
return 'Hello World!'
if __name__ == '__main__':
app.run()