-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
50 lines (38 loc) · 1.37 KB
/
app.py
File metadata and controls
50 lines (38 loc) · 1.37 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from flask import Flask, render_template
from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()
def create_app(config=None):
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///rentflow.db'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
app.config['SECRET_KEY'] = 'dev-secret-key'
if config:
app.config.update(config)
db.init_app(app)
with app.app_context():
from models import Building # noqa: ensure models registered
db.create_all()
if not app.config.get('TESTING'):
if Building.query.first() is None:
from seed import seed_data
seed_data(db)
# Register blueprints
from routes.dashboard import bp as dashboard_bp
from routes.buildings import bp as buildings_bp
from routes.units import bp as units_bp
from routes.payments import bp as payments_bp
from routes.reports import bp as reports_bp
app.register_blueprint(dashboard_bp)
app.register_blueprint(buildings_bp)
app.register_blueprint(units_bp)
app.register_blueprint(payments_bp)
app.register_blueprint(reports_bp)
# Error handlers
@app.errorhandler(404)
def not_found(e):
return render_template('404.html'), 404
return app
# Only run if executed directly
if __name__ == '__main__':
app = create_app()
app.run(debug=True)