-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
36 lines (24 loc) · 791 Bytes
/
main.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
from flask import Flask
from api.views import bp_api
from exceptions.exceptions import DataSourceError
from posts.views import posts
import logger
def create_and_config_app(config_path):
_app = Flask(__name__)
_app.register_blueprint(posts)
_app.register_blueprint(bp_api, url_prefix="/api")
_app.config.from_pyfile(config_path)
logger.config(_app)
return _app
app = create_and_config_app("config.py")
@app.errorhandler(404)
def page_error_404(error):
return f"No such page, {error}", 404
@app.errorhandler(500)
def page_error_500(error):
return f"Error on server side - {error}", 500
@app.errorhandler(DataSourceError)
def page_error_data_source_error(error):
return f"Error on site broken data", 500
if __name__ == "__main__":
app.run()