Ring Example

This application demonstrates three pages linked together.

../_images/ring1.png ../_images/ring2.png ../_images/ring3.png
from bakery import assert_equal
from drafter import route, start_server, Page, Link


@route()
def index():
    return Page(None, [
        "Hello, World!",
        Link("Second page", "second")
    ])


@route
def second():
    return Page(None, [
        "Welcome to the second page.",
        Link("Third page", third)
    ])


@route
def third():
    return Page(None, [
        "Welcome to the third page.",
        Link("Return to start", index)
    ])


assert_equal(index(), Page(None, ["Hello, World!", Link("Second page", "second")]))
assert_equal(second(), Page(None, ["Welcome to the second page.", Link("Third page", third)]))
assert_equal(third(), Page(None, ["Welcome to the third page.", Link("Return to start", index)]))

start_server()