πŸš€ 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 / βžβ€¬ calls views.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:

  1. Duck server starts (main.py)

  2. Request comes in (e.g. /)

  3. urls.py decides which function to call

  4. views.py runs the logic

  5. Response 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.