A lightweight, high-performance static file server built with FastAPI. FastStatic provides an easy way to serve static files with automatic path redirection, logging, and error handling.
- ๐ High-performance static file serving
- ๐ Automatic directory creation
- ๐ Smart path redirection
- ๐ Comprehensive logging with rotation
- โก Built with FastAPI for maximum performance
- ๐ก๏ธ Built-in error handling
- ๐ OpenAPI documentation included
- ๐ Health check endpoint
- Python 3.7+
- pip (Python package installer)
- Clone the repository:
git clone https://github.com/ashwin271/faststatic.git
cd faststatic- Create a virtual environment and activate it:
python -m venv env
source env/bin/activate # On Windows: env\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Place your static files in the
app/staticdirectory - Run the server:
cd app
python main.pyThe server will start on http://0.0.0.0:8800 by default.
- Access files directly via
/static/filename(e.g.,/static/dog.jpg) - Any request to
/filenamewill automatically redirect to/static/filename - Root path (
/) shows a welcome message - Health check available at
/health
Once the server is running, you can access:
- Swagger UI documentation at
/docs - ReDoc documentation at
/redoc
Logs are stored in logs/app.log with the following configuration:
- Rotation: 500 MB
- Retention: 10 days
- Level: INFO
- Format:
YYYY-MM-DD HH:mm:ss | LEVEL | message - Includes backtrace and diagnosis for errors
.
โโโ app
โ โโโ main.py # Main application file
โ โโโ static # Static files directory (you can add your files here)
โโโ logs # Log files directory (created automatically)
โโโ README.md
โโโ requirements.txt
The following settings can be modified in main.py:
STATIC_DIR = Path("static") # Static files directory
HOST = "0.0.0.0" # Host address
PORT = 8800 # Port number- Automatic 404 responses for missing files
- JSON-formatted error responses
- Comprehensive error logging
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.