Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,33 +1,35 @@
|
|
| 1 |
-
from flask import Flask
|
| 2 |
-
from flask_cors import CORS
|
| 3 |
-
from config.database import init_db
|
| 4 |
-
from routes.auth import auth_bp
|
| 5 |
-
from routes.recommend import recommend_bp
|
| 6 |
-
from routes.history import history_bp
|
| 7 |
-
from routes.user import user_bp
|
| 8 |
-
import os
|
| 9 |
-
from dotenv import load_dotenv
|
| 10 |
-
|
| 11 |
-
load_dotenv()
|
| 12 |
-
|
| 13 |
-
app = Flask(__name__)
|
| 14 |
-
app.config['SECRET_KEY'] = os.getenv('SECRET_KEY')
|
| 15 |
-
|
| 16 |
-
# Enable CORS
|
| 17 |
-
CORS(app)
|
| 18 |
-
|
| 19 |
-
# Initialize MongoDB
|
| 20 |
-
init_db()
|
| 21 |
-
|
| 22 |
-
# Register blueprints
|
| 23 |
-
app.register_blueprint(auth_bp, url_prefix='/auth')
|
| 24 |
-
app.register_blueprint(recommend_bp)
|
| 25 |
-
app.register_blueprint(history_bp)
|
| 26 |
-
app.register_blueprint(user_bp, url_prefix='/user')
|
| 27 |
-
|
| 28 |
-
@app.route('/health', methods=['GET'])
|
| 29 |
-
def health_check():
|
| 30 |
-
return {"status": "healthy", "message": "Flask backend is running"}, 200
|
| 31 |
-
|
| 32 |
-
if __name__ ==
|
| 33 |
-
|
|
|
|
|
|
|
|
|
| 1 |
+
from flask import Flask
|
| 2 |
+
from flask_cors import CORS
|
| 3 |
+
from config.database import init_db
|
| 4 |
+
from routes.auth import auth_bp
|
| 5 |
+
from routes.recommend import recommend_bp
|
| 6 |
+
from routes.history import history_bp
|
| 7 |
+
from routes.user import user_bp
|
| 8 |
+
import os
|
| 9 |
+
from dotenv import load_dotenv
|
| 10 |
+
|
| 11 |
+
load_dotenv()
|
| 12 |
+
|
| 13 |
+
app = Flask(__name__)
|
| 14 |
+
app.config['SECRET_KEY'] = os.getenv('SECRET_KEY')
|
| 15 |
+
|
| 16 |
+
# Enable CORS
|
| 17 |
+
CORS(app)
|
| 18 |
+
|
| 19 |
+
# Initialize MongoDB
|
| 20 |
+
init_db()
|
| 21 |
+
|
| 22 |
+
# Register blueprints
|
| 23 |
+
app.register_blueprint(auth_bp, url_prefix='/auth')
|
| 24 |
+
app.register_blueprint(recommend_bp)
|
| 25 |
+
app.register_blueprint(history_bp)
|
| 26 |
+
app.register_blueprint(user_bp, url_prefix='/user')
|
| 27 |
+
|
| 28 |
+
@app.route('/health', methods=['GET'])
|
| 29 |
+
def health_check():
|
| 30 |
+
return {"status": "healthy", "message": "Flask backend is running"}, 200
|
| 31 |
+
|
| 32 |
+
if __name__ == '__main__':
|
| 33 |
+
import os
|
| 34 |
+
port = int(os.environ.get('PORT', 7860))
|
| 35 |
+
app.run(host='0.0.0.0', port=port, debug=False)
|