diff --git a/src/api.py b/src/api.py new file mode 100644 index 0000000000000000000000000000000000000000..fe2411cf443b197b721252db8d57fea6325b7c2a --- /dev/null +++ b/src/api.py @@ -0,0 +1,24 @@ +from fastapi import APIRouter, HTTPException +from fastapi.responses import FileResponse +import os + +router = APIRouter() + +@router.get("/read-file") +async def read_file(file_path: str): + # Define the base directory for public files + base_dir = "/path/to/public/drive" + + # Construct the full file path + full_path = os.path.join(base_dir, file_path) + + # Check if the file exists + if not os.path.isfile(full_path): + raise HTTPException(status_code=404, detail="File not found") + + # Return the file as a response + return FileResponse(full_path) + +@router.get("/hello") +async def hello_world(): + return {"message": "Hello, World!"} \ No newline at end of file diff --git a/src/main.py b/src/main.py new file mode 100644 index 0000000000000000000000000000000000000000..1291fec485ea846ef57db15ce6c1c4e738cd1764 --- /dev/null +++ b/src/main.py @@ -0,0 +1,10 @@ +from fastapi import FastAPI +from src.api import router + +app = FastAPI() + +app.include_router(router) + +if __name__ == "__main__": + import uvicorn + uvicorn.run(app, host="0.0.0.0", port=8000) \ No newline at end of file diff --git a/src/requirements.txt b/src/requirements.txt index d7c2b3f2988de7841d5f98bf551ea1ae10a71591..5836f13e3d1c6829345163cdf283e89c21222b30 100644 --- a/src/requirements.txt +++ b/src/requirements.txt @@ -3,4 +3,5 @@ PyPDF2 scikit-learn transformers streamlit +fastapi