π Getting Started with DuckΒΆ
Simple. Powerful. Reactive web apps in pure Python β no JavaScript, no extra tools.
This guide will get you from zero ββ¬ running app ββ¬ understanding structure in a few minutes.
1. Install DuckΒΆ
pip install duckframework
2. Create Your First ProjectΒΆ
duck makeproject myproject
cd myproject
3. Run the ServerΒΆ
duck runserver # Or use python3 web/main.py
Open your browser:
http://localhost:8000
π Your Duck app is now running.
4. Understand the Project StructureΒΆ
Duck keeps things organized but simple. The most important files are:
web/
βββ main.py
βββ urls.py
βββ views.py
Letβs break them down π
web/main.py ββ¬ Entry Point (starts your app)ΒΆ
#!/usr/bin/env python
"""
Main py script for application creation and execution.
"""
from duck.app import App
app = App(port=8000, addr="0.0.0.0", domain="localhost")
if __name__ == "__main__":
app.run()
What it does:ΒΆ
Creates your Duck application (
App)Configures server settings (port, address, domain)
Starts the server with
app.run()
π Think of this as: βbooting up your backendβ
web/urls.py ββ¬ URL Routing (maps URLs to logic)ΒΆ
Example:
from duck.urls import path
from . import views
urlpatterns = [
path("/", views.home),
]
What it does:ΒΆ
Defines which URL calls which function
Connects user requests ββ¬ your code
π Example:
Visiting
/ββ¬ callsviews.home
web/views.py ββ¬ Logic (what your app does)ΒΆ
Example:
def home():
return "Hello, Duck π¦"
What it does:ΒΆ
Contains your business logic
Returns responses (text, JSON, HTML, etc.)
π This is where you build your app behavior
How Everything ConnectsΒΆ
When a user visits your app:
Duck server starts (
main.py)Request comes in (e.g.
/)urls.pydecides which function to callviews.pyruns the logicResponse is returned to the browser
π Thatβs the full request flow.
Run Built-in TestsΒΆ
duck runtests
Use verbose mode if needed:
duck runtests -v
RequirementsΒΆ
Python 3.10+
What Makes Duck Different?ΒΆ
With most frameworks, you need extra tools like:
Reverse proxy (NGINX)
App server (Gunicorn)
SSL setup
π Duck handles these out of the box.
Final ThoughtΒΆ
Duck is designed to be:
Simple to start π§
Powerful to scale β‘
Flexible to control π§©
Start small. Explore the files. Build something real.
Welcome to Duck.