Browser hot-reloading is a crucial development technique that automatically refreshes your web application when source files change, providing a seamless and efficient development experience for Python ASGI web frameworks like FastAPI.
arel
is a lightweight library designed to implement development-only hot-reloading for non-Python files that are not dynamically read from disk on each request. This includes:
- HTML templates
- GraphQL schemas
- Cached rendered Markdown content
- Static assets
- Real-time file change detection
- WebSocket-based browser notifications
- Customizable reload hooks
- Minimal performance overhead
- File Watching: arel monitors specified files for changes
- WebSocket Notification: When a file is modified, it sends a signal to the browser
- Automatic Reload: An injected client script triggers a page refresh
- Custom Hooks: Developers can register additional server-side reload operations
- Python 3.8+
- FastAPI
- uvicorn
# Clone the repository
git clone https://github.com/ashleymavericks/browser-hot-reloading.git
# Install dependencies
pipenv install # or pip install -r requirements.txt
# Start the FastAPI application with hot-reloading
DEBUG=true uvicorn main:app --reload
For an in-depth explanation of browser hot-reloading and the implementation details, check out the comprehensive blog post:
Supercharge Your FastAPI Development with Browser Hot Reloading Using Arel
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.