This repository contains a FastAPI-based file upload system. It allows users to upload files via a React frontend and store them in a local directory.
- Upload files to the FastAPI backend.
- Store files in a designated local directory.
- Integration with a React frontend.
Ensure you have Python 3 installed. Then, install FastAPI and Uvicorn:
pip install fastapi uvicorn python-multipartuvicorn main:app --reloadThis will start the server at http://127.0.0.1:8000/.
Navigate to:
- Swagger UI – Test the
/upload/endpoint.
Uploaded files are saved in the uploads/ directory. Ensure this folder exists before running the server:
mkdir -p uploads- Endpoint:
POST /upload/ - Request: Multipart form data with a file.
- Response: JSON containing the filename and status.
Example:
{
"filename": "example.txt",
"status": "uploaded successfully"
}To integrate with React:
- Implement a frontend file upload form.
- Use
fetch()to send files tohttp://127.0.0.1:8000/upload/. - Display success/error messages.
- Implement file listing and retrieval.
- Improve error handling.
- Enhance UI for better user experience.
This project is open-source. Modify as needed