File size: 997 Bytes
54bf42b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9e7432b
 
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
import requests
from flask import Flask, request, jsonify

app = Flask(__name__)
data = None  # This will store the last stored JSON data

@app.route('/', methods=['POST'])
def store_data():
    json_data = request.get_json()  # Get the JSON data from the request
    json_response = send_request_to_api(json_data)  # Send the request to the target API and get the JSON response
    global data
    data = json_response  # Update the last stored JSON data
    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={})  # Disable the proxy configuration
    return response.json()  # Return the JSON response

@app.route('/', methods=['GET'])
def get_data():
    return jsonify(data)

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=7860)