Repository navigation
Expand file tree
/
Copy pathapp.py
More file actions
64 lines (55 loc) · 1.67 KB
/
Copy pathapp.py
File metadata and controls
64 lines (55 loc) · 1.67 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
from flask import Flask, jsonify
from flask_cors import CORS
from config import Config
from auth import auth_bp
from video import video_bp
# Create Flask app
app = Flask(__name__)
# Load configuration
app.config.from_object(Config)
# Enable CORS (allows React Native to make requests)
CORS(app, resources={
r"/*": {
"origins": "*", # In production, specify your app's origin
"methods": ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
"allow_headers": ["Content-Type", "Authorization"]
}
})
# Register blueprints
app.register_blueprint(auth_bp)
app.register_blueprint(video_bp)
# Root route
@app.route('/', methods=['GET'])
def home():
"""Health check endpoint"""
return jsonify({
'message': 'Video App API',
'status': 'running',
'version': '1.0.0'
}), 200
# Error handlers
@app.errorhandler(404)
def not_found(error):
"""Handle 404 errors"""
return jsonify({'error': 'Endpoint not found'}), 404
@app.errorhandler(500)
def internal_error(error):
"""Handle 500 errors"""
return jsonify({'error': 'Internal server error'}), 500
# Run app
if __name__ == '__main__':
print("=" * 50)
print("🚀 Video App Backend Starting...")
print("=" * 50)
print(f"Environment: {Config.DEBUG and 'Development' or 'Production'}")
print(f"MongoDB: {Config.MONGODB_URI}")
print("=" * 50)
print("Available endpoints:")
print(" POST /auth/signup")
print(" POST /auth/login")
print(" GET /auth/me")
print(" POST /auth/logout")
print(" GET /dashboard")
print(" GET /video/<id>/stream")
print("=" * 50)
app.run(debug=Config.DEBUG, host='0.0.0.0', port=5000)