-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapplication.py
46 lines (33 loc) · 1.2 KB
/
application.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
42
43
44
from dotenv import load_dotenv
# To load environment variables
load_dotenv()
from flask import Flask
from flask_admin import Admin
from flask_admin.contrib.sqla import ModelView
from settings.extension import db, migrate, ma, swagger
from apps.AuthApp.router import AuthApp, models
# Flask App initialize with extensions and run
def create_app():
# Flask app initialize
app = Flask(__name__)
app.config.from_pyfile('settings/configuration.py')
# Flask Admin
app.config['FLASK_ADMIN_SWATCH'] = 'cerulean'
admin = Admin(app, name='Flask Admin Panel', template_mode='bootstrap4')
admin.add_view(ModelView(models.User, db.session, category='Auth'))
admin.add_view(ModelView(models.EmailHandler, db.session, category='Auth'))
# Blueprints
app.register_blueprint(AuthApp, url_prefix='/auth')
# Database connection initialize
db.init_app(app)
# Marshmallow initialize
ma.init_app(app)
# Database migrate initialize
migrate.init_app(app, db)
# Swagger initialize
swagger.init_app(app)
# Return App for run in run.py file
return app
# Run Application
if __name__ == "__main__":
create_app().run(debug=True, host='0.0.0.0', port='5001')