init
Browse files- Dockerfile +10 -0
- app.py +26 -0
- requirements.txt +2 -0
Dockerfile
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.8-slim-buster
|
| 2 |
+
|
| 3 |
+
WORKDIR /app
|
| 4 |
+
|
| 5 |
+
COPY requirements.txt requirements.txt
|
| 6 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 7 |
+
|
| 8 |
+
COPY . .
|
| 9 |
+
|
| 10 |
+
CMD ["python", "app.py", "--host", "0.0.0.0", "--port", "7860"]
|
app.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import requests
|
| 2 |
+
from flask import Flask, request, jsonify
|
| 3 |
+
|
| 4 |
+
app = Flask(__name__)
|
| 5 |
+
data = None # This will store the last stored JSON data
|
| 6 |
+
|
| 7 |
+
@app.route('/', methods=['POST'])
|
| 8 |
+
def store_data():
|
| 9 |
+
json_data = request.get_json() # Get the JSON data from the request
|
| 10 |
+
json_response = send_request_to_api(json_data) # Send the request to the target API and get the JSON response
|
| 11 |
+
global data
|
| 12 |
+
data = json_response # Update the last stored JSON data
|
| 13 |
+
return jsonify({'message': 'Data stored successfully'})
|
| 14 |
+
|
| 15 |
+
def send_request_to_api(json_data):
|
| 16 |
+
url = 'https://etahamad-new-plant-disease-detection.hf.space/run/predict'
|
| 17 |
+
headers = {'Content-Type': 'application/json'}
|
| 18 |
+
response = requests.post(url, json=json_data, headers=headers, proxies={}) # Disable the proxy configuration
|
| 19 |
+
return response.json() # Return the JSON response
|
| 20 |
+
|
| 21 |
+
@app.route('/', methods=['GET'])
|
| 22 |
+
def get_data():
|
| 23 |
+
return jsonify(data)
|
| 24 |
+
|
| 25 |
+
if __name__ == '__main__':
|
| 26 |
+
app.run()
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Flask
|
| 2 |
+
requests
|