Spaces:
Sleeping
Sleeping
| from flask import Flask, request, jsonify | |
| import os | |
| app = Flask(__name__) | |
| def home(): | |
| return jsonify({ | |
| "message": "Flask Backend is running!", | |
| "status": "success" | |
| }) | |
| def health_check(): | |
| return jsonify({"status": "healthy", "service": "flask-backend"}) | |
| def predict(): | |
| try: | |
| data = request.get_json() | |
| # Add your prediction logic here | |
| return jsonify({ | |
| "prediction": "sample_result", | |
| "input_data": data, | |
| "status": "success" | |
| }) | |
| except Exception as e: | |
| return jsonify({"error": str(e)}), 400 | |
| if __name__ == '__main__': | |
| port = int(os.environ.get('PORT', 7860)) | |
| app.run(debug=False, host='0.0.0.0', port=port) |