|
import requests |
|
from flask import Flask, request, jsonify |
|
|
|
app = Flask(__name__) |
|
data = None |
|
|
|
@app.route('/', methods=['POST']) |
|
def store_data(): |
|
json_data = request.get_json() |
|
json_response = send_request_to_api(json_data) |
|
global data |
|
data = json_response |
|
return jsonify({'message': 'Data stored successfully'}) |
|
|
|
def send_request_to_api(json_data): |
|
url = 'https://etahamad-new-plant-disease-detection.hf.space/run/predict' |
|
headers = {'Content-Type': 'application/json'} |
|
response = requests.post(url, json=json_data, headers=headers, proxies={}) |
|
return response.json() |
|
|
|
@app.route('/', methods=['GET']) |
|
def get_data(): |
|
return jsonify(data) |
|
|
|
if __name__ == '__main__': |
|
app.run(host='0.0.0.0', port=7860) |
|
|