25 lines
700 B
Python
25 lines
700 B
Python
from flask import Flask
|
|
import os
|
|
|
|
def create_app():
|
|
app = Flask(__name__)
|
|
|
|
if os.getenv("PYROM_PROD") is None:
|
|
app.static_folder = os.path.join(os.path.dirname(__file__), "../data/static")
|
|
app.debug = True
|
|
app.config["DB_PATH"] = "data/db/db.dev.sqlite"
|
|
else:
|
|
app.config["DB_PATH"] = "data/db/db.prod.sqlite"
|
|
|
|
os.makedirs(os.path.dirname(app.config["DB_PATH"]), exist_ok = True)
|
|
with app.app_context():
|
|
from .schema import create as create_tables
|
|
from .migrations import run_migrations
|
|
create_tables()
|
|
run_migrations()
|
|
|
|
from app.routes.app import bp as app_bp
|
|
app.register_blueprint(app_bp)
|
|
|
|
return app
|