A lightweight, fast, and easy-to-use Python web framework built for speed and simplicity. Inspired by modern frameworks like FastAPI, SmallFast provides an elegant API to build web applications and APIs quickly with minimal boilerplate.
- Intuitive Routing: Decorator-based routing for
GET,POST,PUT,DELETE,PATCH,OPTIONS,HEAD, and flexible custom routes. - Path Parameters: Easily extract values from URL paths (e.g.,
/users/{id}). - Data Validation & Parsing: Automatic parsing of request bodies into Python
dataclasses. - Middleware Support: Robust support for both global and route-level middleware. Use
req.stateto pass data between middleware and handlers. - Built-in Admin Panel: Out-of-the-box admin application with authentication and session management.
- Error Handling: Raised
HTTPExceptionclass to handle errors gracefully and provide consistent responses.
Explore the admin panel interface with our interactive screenshots:
- 📊 Dashboard - Overview of your application
- 🔐 Login - Admin authentication
- 📚 Documentation - API documentation
- 📝 Request Logs - View all requests
- 🧭 Routes - All registered routes
- ⚙️ Settings - Application configuration
Clone the repository and start building:
git clone https://github.com/yourusername/SmallFast.git
cd SmallFast
# We recommend using a virtual environment
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt # (if any)Create an app.py file with your routes:
from pybackend import App, HTTPException
from dataclasses import dataclass
app = App()
# Basic GET Request
@app.get("/")
def home():
return {"status": "online", "message": "Welcome to SmallFast!"}
# Path Parameters
@app.get("/users/{user_id}")
def get_user(user_id):
if user_id != "1":
raise HTTPException(404, "User not found")
return {"id": user_id, "name": "Admin"}
# Automatic Request Body Parsing using Dataclasses
@dataclass
class UserCreate:
name: str
email: str
@app.post("/users")
def create_user(user: UserCreate):
# 'user' is automatically parsed from JSON body to the UserCreate dataclass
return {"created": True, "name": user.name, "email": user.email}
if __name__ == "__main__":
app.run(port=8080)Run your code:
python app.pyYour server will start and be available at http://localhost:8080.
SmallFast supports powerful middleware injection to handle requests and responses globally or per route.
@app.middleware
def request_logger(req, res, next):
print(f"[{req.method}] {req.path}")
# Proceed to next middleware or route handler
return next()Route-level middlewares can be used to protect specific endpoints (e.g., Auth Guards).
def require_api_key(req, res):
if req.headers.get("X-API-Key") != "secret":
raise HTTPException(401, "Missing or invalid API key")
@app.get("/secure", middleware=[require_api_key])
def secure_data(req):
return {"authorized": True, "data": "Top secret information"}Middleware can:
- Read and mutate the
req(Request) object. - Pass shared data using
req.state. - Stop the request prematurely by raising an
HTTPException. - Block or proceed execution by utilizing the
nextfunction.
SmallFast ships with a built-in interactive Admin Panel. By enabling it, you get login pages, secure cookie authentication, and routing settings out of the box!
app = App()
admin_panel = app.admin_panel
admin_panel.register()
if __name__ == "__main__":
app.run(port=8080, admin=True)Navigate to http://localhost:8080/admin/login to access the portal. The built-in panel supports role-based access, credential updates, and session cookies for a secure administrative experience.