Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
@@ -24,6 +24,17 @@ CODE_TO_PLANT = {
|
|
24 |
@app.get("/health")
|
25 |
async def api_health_check():
|
26 |
return JSONResponse(content={"status": "Service is running"})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
@app.get("/download_by_code/{code}")
|
29 |
async def download_model_by_code(code: str):
|
@@ -41,3 +52,5 @@ async def download_model_by_code(code: str):
|
|
41 |
|
42 |
if __name__ == "__main__":
|
43 |
uvicorn.run(app, host="0.0.0.0", port=7860)
|
|
|
|
|
|
24 |
@app.get("/health")
|
25 |
async def api_health_check():
|
26 |
return JSONResponse(content={"status": "Service is running"})
|
27 |
+
|
28 |
+
@app.get("/download/{plant_name}")
|
29 |
+
async def download_model(plant_name: str):
|
30 |
+
filename = f"model_{plant_name}.tflite"
|
31 |
+
file_path = os.path.join(MODEL_DIRECTORY, filename)
|
32 |
+
|
33 |
+
# Check if file exists
|
34 |
+
if not os.path.isfile(file_path):
|
35 |
+
raise HTTPException(status_code=404, detail=f"Model file '{filename}' not found")
|
36 |
+
|
37 |
+
return FileResponse(file_path, filename=filename, media_type="application/octet-stream")
|
38 |
|
39 |
@app.get("/download_by_code/{code}")
|
40 |
async def download_model_by_code(code: str):
|
|
|
52 |
|
53 |
if __name__ == "__main__":
|
54 |
uvicorn.run(app, host="0.0.0.0", port=7860)
|
55 |
+
|
56 |
+
|