-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflask-server.py
More file actions
28 lines (21 loc) · 804 Bytes
/
flask-server.py
File metadata and controls
28 lines (21 loc) · 804 Bytes
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
from flask import Flask, request, jsonify
from flask_cors import CORS
from prompt import response#, save_data_for_matlab
app = Flask(__name__)
CORS(app) # Allow CORS for all domains and routes
@app.route('/run-model', methods=['POST'])
def run_model():
data = request.json
location = data.get('location')
if not location:
return jsonify({"error": "Location not provided"}), 400
try:
# Run the ML model (OpenAI)
regions, output = response(location)
# Save data for MATLAB processing
# save_data_for_matlab(regions)
return ({"regions": output})
except Exception as e:
return jsonify({"error": "Internal server error", "details": str(e)}), 500
if __name__ == '__main__':
app.run(host='127.0.0.1', port=5001, debug=True)