Spaces:
Running
Running
Delete app.py
Browse files
app.py
DELETED
@@ -1,49 +0,0 @@
|
|
1 |
-
import os
|
2 |
-
import sys
|
3 |
-
# DON'T CHANGE THIS !!!
|
4 |
-
sys.path.insert(0, os.path.dirname(__file__))
|
5 |
-
|
6 |
-
from flask import Flask, send_from_directory
|
7 |
-
from flask_cors import CORS
|
8 |
-
from src.models.user import db
|
9 |
-
from src.routes.user import user_bp
|
10 |
-
from src.routes.post import post_bp
|
11 |
-
|
12 |
-
app = Flask(__name__, static_folder=os.path.join(os.path.dirname(__file__), 'src', 'static'))
|
13 |
-
app.config['SECRET_KEY'] = 'asdf#FGSgvasgf$5$WGT'
|
14 |
-
|
15 |
-
# Enable CORS for all routes
|
16 |
-
CORS(app)
|
17 |
-
|
18 |
-
app.register_blueprint(user_bp, url_prefix='/api')
|
19 |
-
app.register_blueprint(post_bp, url_prefix='/api')
|
20 |
-
|
21 |
-
# Database configuration
|
22 |
-
app.config['SQLALCHEMY_DATABASE_URI'] = f"sqlite:///{os.path.join(os.path.dirname(__file__), 'src', 'database', 'app.db')}"
|
23 |
-
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
|
24 |
-
db.init_app(app)
|
25 |
-
|
26 |
-
# Create database tables
|
27 |
-
with app.app_context():
|
28 |
-
db.create_all()
|
29 |
-
|
30 |
-
@app.route('/', defaults={'path': ''})
|
31 |
-
@app.route('/<path:path>')
|
32 |
-
def serve(path):
|
33 |
-
static_folder_path = app.static_folder
|
34 |
-
if static_folder_path is None:
|
35 |
-
return "Static folder not configured", 404
|
36 |
-
|
37 |
-
if path != "" and os.path.exists(os.path.join(static_folder_path, path)):
|
38 |
-
return send_from_directory(static_folder_path, path)
|
39 |
-
else:
|
40 |
-
index_path = os.path.join(static_folder_path, 'index.html')
|
41 |
-
if os.path.exists(index_path):
|
42 |
-
return send_from_directory(static_folder_path, 'index.html')
|
43 |
-
else:
|
44 |
-
return "index.html not found", 404
|
45 |
-
|
46 |
-
if __name__ == '__main__':
|
47 |
-
port = int(os.environ.get('PORT', 7860))
|
48 |
-
app.run(host='0.0.0.0', port=port, debug=False)
|
49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|