-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
66 lines (51 loc) · 1.66 KB
/
app.py
File metadata and controls
66 lines (51 loc) · 1.66 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import os
from flask import Flask, jsonify, render_template, redirect, url_for
from flask_cors import CORS
from dotenv import load_dotenv
# Import routes
from app.routes.auth import auth_bp
from app.routes.user import user_bp
from app.database import init_app
# Load environment variables
load_dotenv()
def create_app():
app = Flask(__name__,
template_folder='app/templates',
static_folder='app/static')
# Configure app
app.config['SECRET_KEY'] = os.getenv('SECRET_KEY', 'dev-secret-key')
app.config['JWT_SECRET_KEY'] = os.getenv('JWT_SECRET_KEY', 'dev-jwt-secret')
# Initialize database
init_app(app)
# Enable CORS
CORS(app)
# Register blueprints
app.register_blueprint(auth_bp, url_prefix='/api/auth')
app.register_blueprint(user_bp, url_prefix='/api/user')
# Home route redirects to login
@app.route('/')
def index():
return redirect(url_for('login'))
# Serve login page
@app.route('/login')
def login():
return render_template('login.html')
# Serve signup page
@app.route('/signup')
def signup():
return render_template('signup.html')
# Serve dashboard page
@app.route('/dashboard')
def dashboard():
return render_template('dashboard.html')
# Error handlers
@app.errorhandler(404)
def not_found(e):
return jsonify({"error": "Resource not found"}), 404
@app.errorhandler(500)
def internal_server_error(e):
return jsonify({"error": "Internal server error"}), 500
return app
if __name__ == '__main__':
app = create_app()
app.run(debug=True)