This is a basic FastAPI application that demonstrates file uploads and downloads.
-
Create a virtual environment (optional but recommended):
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install dependencies:
pip install -r requirements.txt
Use uvicorn to run the application:
uvicorn main:app --reloadThis will start the server, typically at http://127.0.0.1:8000.
-
Navigate to
http://127.0.0.1:8000in your browser to see the welcome message. -
Navigate to
http://127.0.0.1:8000/docsfor the interactive API documentation (Swagger UI). -
Use a tool like
curlor Postman to send a POST request to the/processfile/endpoint with a file attached.Example using
curl:curl -X POST "http://127.0.0.1:8000/processfile/" -F "file=@your_file_name.txt" -o output.txt
Replace
your_file_name.txtwith the path to the file you want to upload. The processed (mocked) output will be saved tooutput.txt.