Drafter is an educational web development library for Python. It enables students to learn and practice programming concepts by building dynamic, interactive websites.

Features

Examples and Getting Started

You can install Drafter using your favorite editor’s GUI, or via pip on the command line:

pip install drafter

The simplest Drafter site is quite short:

from drafter import *

start_server()

But it’s not hard to make something more sophisticated!

from drafter import *
from dataclasses import dataclass

@dataclass
class State:
    counter: int

@route
def index(state: State) -> Page:
    return Page(state, [
        "Welcome to Drafter!",
        "Click the button below.",
        Button("Increase the count", increment_counter)
    ])

@route
def increment_counter(state: State) -> Page:
    state.counter += 1
    return Page(state, [
      "You've clicked the button " + str(state.counter) + " times",
      Button("Click again", increment_counter)
    ])

start_server(State(0))

Explore Tutorials

Documentation

Ready to learn more? Check out the student-friendly Drafter Documentation!

About Drafter’s Team

Drafter was created to simplify web development for students learning Python. The team includes passionate educators and developers dedicated to advancing programming education.

Follow us!