-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
66 lines (51 loc) · 1.49 KB
/
Copy pathapp.py
File metadata and controls
66 lines (51 loc) · 1.49 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
54
55
56
57
58
59
60
61
62
63
64
65
66
import os
from flask import Flask
from flask_wtf.csrf import CSRFError
from config import Config
from database.models import *
from extensions import csrf, db, init_cloudinary, limiter, migrate, server_session
from routes import *
from routes.errors_route import (
bad_request,
csrf_error,
forbidden_page,
max_requests,
not_allowed,
not_found,
server_error,
)
from security import init_security
def create_app():
app = Flask(__name__)
app.config.from_object(Config)
db.init_app(app)
migrate.init_app(app, db)
csrf.init_app(app)
limiter.init_app(app)
server_session.init_app(app)
init_cloudinary(app)
init_security(app)
app.register_blueprint(main)
app.register_blueprint(customer)
app.register_blueprint(staff)
app.register_blueprint(books)
app.register_error_handler(CSRFError, csrf_error)
app.register_error_handler(400, bad_request)
app.register_error_handler(403, forbidden_page)
app.register_error_handler(404, not_found)
app.register_error_handler(405, not_allowed)
app.register_error_handler(429, max_requests)
app.register_error_handler(500, server_error)
app.register_error_handler(413, large_file)
with app.app_context():
db.create_all()
return app
app = create_app()
if __name__ == "__main__":
port = int(os.environ.get("PORT", 5000))
# port = int(os.environ.get("PORT", 10000))
app.run(
debug=False,
host="0.0.0.0",
port=port,
)