forked from olexandr-klymenko/IMDB2sql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
35 lines (25 loc) · 889 Bytes
/
app.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
from os import getcwd
from pathlib import Path
from flask import Flask, render_template
from flask_graphql import GraphQLView
from src.models import db
from src.schema import schema
from src.utils import get_config
CONFIG = get_config(Path(Path(getcwd()) / "config" / "config.yml"))
def create_app(config=CONFIG) -> Flask:
app = Flask(__name__, template_folder="src/templates", static_folder="src/static")
app.debug = True
app.config["SQLALCHEMY_DATABASE_URI"] = config["default_database_uri"]
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = True
db.init_app(app)
app.add_url_rule(
"/graphql",
view_func=GraphQLView.as_view("graphql", schema=schema, graphiql=True),
)
@app.route("/")
def index() -> str:
return render_template("index.html")
return app
if __name__ == "__main__":
app = create_app()
app.run()