pub1c-web/app/app.py

30 lines
717 B
Python
Raw Permalink Normal View History

2021-10-07 11:31:12 +00:00
from flask import Flask, render_template
from flask_restful import Api
from flask_cors import CORS
from app.api.index import add_api_resources
from app.glob import get_config, get_manager
frontend_dir = '../frontend/dist'
2021-10-07 11:37:03 +00:00
def create_app() -> Flask:
2021-10-07 11:31:12 +00:00
app = Flask(__name__, static_url_path='/', static_folder=frontend_dir, template_folder=frontend_dir)
api = Api(app, '/api/v1/')
add_api_resources(api)
cors = CORS(app, resources={r"/api/*": {"origins": "*"}})
2021-10-07 11:41:08 +00:00
index_content: str = ""
2021-10-07 11:31:12 +00:00
@app.route('/')
def index():
return index_content
with app.app_context():
get_config()
get_manager()
index_content = render_template("index.html")
return app