Skip to content

Commit 323c376

Browse files
committed
feat: added RESTful api
1 parent 76a6748 commit 323c376

25 files changed

Lines changed: 82 additions & 1094 deletions

api/api.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
from fastapi import FastAPI, HTTPException
2+
from fastapi.responses import FileResponse
3+
import pandas as pd
4+
import os
5+
6+
app = FastAPI()
7+
8+
IMAGE_DIR = "./images"
9+
CSV_FILES = {
10+
"dataset1": "./data/camera_feed.csv",
11+
"dataset2": "./data/station_feed.csv"
12+
}
13+
14+
@app.get("/data/{dataset_id}")
15+
def get_csv_data(dataset_id: str):
16+
17+
if dataset_id not in CSV_FILES:
18+
raise HTTPException(status_code=404, detail="Dataset not found.")
19+
20+
csv_path = CSV_FILES[dataset_id]
21+
22+
if not os.path.exists(csv_path):
23+
raise HTTPException(status_code=500, detail="CSV file missing on server.")
24+
25+
df = pd.read_csv(csv_path)
26+
return df.to_dict(orient="records")
27+
28+
@app.get("/images/{image_name}")
29+
def get_image(image_name: str):
30+
31+
image_path = os.path.join(IMAGE_DIR, image_name)
32+
33+
if not os.path.exists(image_path) or not os.path.isfile(image_path):
34+
raise HTTPException(status_code=404, detail="Image not found.")
35+
36+
return FileResponse(image_path)

beestation.py

Lines changed: 0 additions & 175 deletions
This file was deleted.

detectabee-main/README.md

Lines changed: 0 additions & 65 deletions
This file was deleted.

0 commit comments

Comments
 (0)