2022-03-17 08:26:25 +00:00
|
|
|
from apiflask import APIFlask
|
|
|
|
|
2022-03-13 19:43:24 +00:00
|
|
|
from dotenv import load_dotenv
|
2022-03-17 12:33:19 +00:00
|
|
|
from flask_cors import CORS
|
2022-03-13 19:43:24 +00:00
|
|
|
|
2022-03-14 16:36:38 +00:00
|
|
|
from models import *
|
|
|
|
from api_blueprint_keyword import keyword_blueprint
|
|
|
|
from api_blueprint_shares import shares_blueprint
|
|
|
|
from api_blueprint_user import users_blueprint
|
2022-03-14 17:13:16 +00:00
|
|
|
from api_blueprint_transactions import transaction_blueprint
|
2022-03-15 07:14:54 +00:00
|
|
|
from api_blueprint_portfolio import portfolio_blueprint
|
2022-03-13 20:00:14 +00:00
|
|
|
|
2022-03-08 14:11:39 +00:00
|
|
|
|
2022-03-13 19:43:24 +00:00
|
|
|
def create_app():
|
|
|
|
load_dotenv()
|
|
|
|
|
|
|
|
# Create Flask app load app.config
|
2022-03-17 16:22:04 +00:00
|
|
|
application = APIFlask(__name__, docs_path='/api/docs')
|
2022-03-13 19:43:24 +00:00
|
|
|
application.config.from_object("config.ConfigClass")
|
|
|
|
|
2022-03-17 16:54:32 +00:00
|
|
|
CORS(application, resource={
|
|
|
|
r"/*": {
|
|
|
|
"origins": "*"
|
|
|
|
}
|
|
|
|
})
|
2022-03-17 12:33:19 +00:00
|
|
|
|
2022-03-13 19:43:24 +00:00
|
|
|
application.app_context().push()
|
|
|
|
|
|
|
|
db.init_app(application)
|
|
|
|
|
2022-03-13 20:00:14 +00:00
|
|
|
# Create all tables
|
|
|
|
db.create_all()
|
|
|
|
|
2022-03-14 16:10:00 +00:00
|
|
|
# api blueprints
|
|
|
|
application.register_blueprint(keyword_blueprint)
|
|
|
|
application.register_blueprint(shares_blueprint)
|
2022-03-14 17:13:16 +00:00
|
|
|
application.register_blueprint(transaction_blueprint)
|
2022-03-14 22:40:36 +00:00
|
|
|
application.register_blueprint(portfolio_blueprint)
|
2022-03-14 16:10:00 +00:00
|
|
|
application.register_blueprint(users_blueprint)
|
|
|
|
|
2022-03-13 19:43:24 +00:00
|
|
|
return application
|
|
|
|
|
|
|
|
|
|
|
|
app = create_app()
|
|
|
|
|
|
|
|
# Start development web server
|
2022-03-08 14:11:39 +00:00
|
|
|
if __name__ == '__main__':
|
2022-03-12 19:21:26 +00:00
|
|
|
app.run()
|