{"id":23913392,"url":"https://github.com/seapagan/fastapi-upload-test","last_synced_at":"2026-05-18T14:09:42.134Z","repository":{"id":270822901,"uuid":"911555507","full_name":"seapagan/fastapi-upload-test","owner":"seapagan","description":"Testing and playing around with file uploads in fastapi and Jinja2 templates","archived":false,"fork":false,"pushed_at":"2025-01-03T14:30:58.000Z","size":58,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-18T21:36:30.073Z","etag":null,"topics":["fastapi","jinja2","python","python3","upload-file"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/seapagan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-03T09:45:05.000Z","updated_at":"2025-12-23T16:24:35.000Z","dependencies_parsed_at":"2025-01-03T11:22:33.866Z","dependency_job_id":"3ecc9755-78dd-46b7-b4fd-24b40d3e96e1","html_url":"https://github.com/seapagan/fastapi-upload-test","commit_stats":null,"previous_names":["seapagan/fastapi-upload-test"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/seapagan/fastapi-upload-test","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seapagan%2Ffastapi-upload-test","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seapagan%2Ffastapi-upload-test/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seapagan%2Ffastapi-upload-test/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seapagan%2Ffastapi-upload-test/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/seapagan","download_url":"https://codeload.github.com/seapagan/fastapi-upload-test/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seapagan%2Ffastapi-upload-test/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33180390,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-18T09:27:30.708Z","status":"ssl_error","status_checked_at":"2026-05-18T09:27:28.300Z","response_time":71,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fastapi","jinja2","python","python3","upload-file"],"created_at":"2025-01-05T09:44:48.601Z","updated_at":"2026-05-18T14:09:42.101Z","avatar_url":"https://github.com/seapagan.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FastAPI File Upload Test\n\nThis is a simple test project to demonstrate file upload functionality using\n**FastAPI**. The project includes a backend API built with FastAPI and a\nfrontend HTML form for uploading files. The app only returns the file size but\nthe backend can obvoiusly perform any action on the file and return custom data.\n\n## Features\n\n- **FastAPI Backend**: Handles file uploads and saves them to a specified\n  directory.\n- **Jinja2 Frontend**: Allows uploading a file and usesd websockets to update\n  the page.\n- **Simple and Lightweight**: Minimal setup required to get started.\n- **Max File Size**: The maximum file size is set to 100 MB. This is checked\n  both on the frontend and again on the backend (browser file-size calcs are\n  often not 100% accurate so files that are close to the limit will slip\n  through and be caught be the backend).\n\n## Repository\n\nThe project is hosted on GitHub:\n[https://github.com/seapagan/fastapi-upload-test](https://github.com/seapagan/fastapi-upload-test)\n\n---\n\n## Prerequisites\n\nBefore running the project, ensure you have the following installed:\n\n- **Python 3.9+**\n- **uv** (For package and environment management). Get it from\n  [here](https://astral.sh/blog/uv) if you don't already have it.\n\n---\n\n## Installation\n\n1. Clone the repository:\n\n   ```terminal\n   git clone https://github.com/seapagan/fastapi-upload-test.git\n   cd fastapi-upload-test\n   ```\n\n2. Create a virtual environment and install the dependencies:\n\n   ```terminal\n   uv sync\n   source ./.venv/bin/activate  # On Windows: .venv\\Scripts\\activate\n   ```\n\n---\n\n## Running the Project\n\n1. Start the FastAPI server using Uvicorn:\n\n   ```bash\n   uvicorn main:app --reload\n   ```\n\n2. Open your browser and navigate to the frontend form:\n\n   ```pre\n   \u003chttp://127.0.0.1:8000\u003e\n   ```\n\n3. Use the form to upload a file:\n   - Click the **Choose File** button to select a file.\n   - Click **Upload** to submit the file to the server.\n\n---\n\n## Project Structure\n\n```pre\nfastapi-upload-test/\n├── main.py               # FastAPI application and routes\n├── templates/            # HTML templates for the frontend\n│   └── index.html        # Frontend with the file upload form\n├── static/               # Static files (CSS, JS, etc.)\n│   ├── script.js         # Custom JavaScript for the form\n│   └── styles.css        # Custom styles for the form\n├── pyproject.toml        # Project metadata and dependencies\n├── uv.lock               # Lock file for uv package manager\n├── README.md             # Project documentation\n└── uploads/              # Directory where uploaded files are saved (created automatically)\n```\n\n---\n\n## Backend Details\n\nThe backend is built using **FastAPI** and provides a single endpoint for file uploads:\n\n- **Endpoint**: `/upload/`\n- **Method**: `POST`\n- **Description**: Accepts a file upload and saves it to the `uploads/` directory.\n\nInternally, the backend will update the file size on the front end using\n**websockets**, after saving the file locally on the server. In a real app you\nwould want to delete the file after processing it to avoid filling up the disk\nor periodically clean up the directory.\n\nWe could just return the file size in the response, but this is a good example\nof how to use websockets with FastAPI and how to update the frontend in real\ntime. In reality the actual process may be longer-running, so this way the user\ncan see that the upload was successful while the processing continues in the\nbackground.\n\n### Example Request\n\n```bash\ncurl -X POST -F \"file=@/path/to/your/file.txt\" \u003chttp://127.0.0.1:8000/upload/\u003e\n```\n\n---\n\n## Frontend Details\n\nThe frontend consists of an HTML form to allow uploading a file to the backend.\nThe form uses **Jinja2** templating to render the HTML and **websockets** to\nupdate the page with the file size after uploading.\n\n---\n\n## Contributing\n\nContributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.\n\n---\n\n## License\n\nThis project is open-source and available under the [MIT License](LICENSE).\n\n---\n\n## Acknowledgments\n\n- **FastAPI** for providing a modern and fast web framework.\n- **Uvicorn** for serving the application.\n\n---\n\nEnjoy testing and experimenting with file uploads using FastAPI! 🚀\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseapagan%2Ffastapi-upload-test","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fseapagan%2Ffastapi-upload-test","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseapagan%2Ffastapi-upload-test/lists"}