scaffold: project structure, config, Flask app factory, test fixtures
Made-with: Cursor
This commit is contained in:
29
app.py
Normal file
29
app.py
Normal file
@@ -0,0 +1,29 @@
|
||||
import os
|
||||
from flask import Flask
|
||||
from flask_sqlalchemy import SQLAlchemy
|
||||
import config
|
||||
|
||||
db = SQLAlchemy()
|
||||
|
||||
|
||||
def create_app():
|
||||
app = Flask(__name__)
|
||||
app.config.from_object(config)
|
||||
app.config["SECRET_KEY"] = os.urandom(24)
|
||||
|
||||
os.makedirs(config.DATA_DIR, exist_ok=True)
|
||||
os.makedirs(config.IMAGES_DIR, exist_ok=True)
|
||||
os.makedirs(config.ISSUES_DIR, exist_ok=True)
|
||||
|
||||
db.init_app(app)
|
||||
|
||||
with app.app_context():
|
||||
from src import models # noqa: F401
|
||||
db.create_all()
|
||||
|
||||
return app
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = create_app()
|
||||
app.run(host="0.0.0.0", port=5000, debug=True)
|
||||
Reference in New Issue
Block a user