.. _fulldocs: Drafter Documentation for Students =================================== This is the Student documentation for the Drafter web framework. This file is organized into the following sections: 1. `Basic Routing`_: How to create routes and pages for your website. 2. `Server Control`_: How to start the server and launch the website. 3. `Components`_: The different components you can use to build your pages. 4. `Debug Information`_: How to show and hide the debug information at the bottom of the page. Basic Routing ------------- .. _route: .. decorator:: route route(url) Decorator to turn a function into route connected to a URL. If the `url` is not given, then the function's name will be used as the route. Unless the name of the function is `index`, in which case that route will be used as the index of the website (the front, default page). :param url: The URL to connect to the function as a route. Defaults to function's name, if not given. :type url: str Pages ----- .. function:: Page(state, content) Page(state, content, js) Constructor function for the ``Page`` object, which holds all the information for a viewable web page. The `state` is hidden from the user, but the `content` is rendered into HTML. This should be returned from any `route` function. The `content` is a list of either string values or `Component` instances. The strings can contain actual HTML, which will be injected directly into the page. The `Component` instances will also be turned into HTML. :param state: The new value of the page, hidden from the user. This is usually an instance of a dataclass. If there is no change to the state, then will just be the `state` parameter. :param content: The actual content of the page, eventually rendered as HTML in the browser. Can combine both string values and `Component` instances. :type content: list[str | Component] :param js: Optional JavaScript code to include in the page. This should be a string containing valid JavaScript, or a list of strings, each containing valid JavaScript code. If a list is provided, each string will be included in the page in the order they are given. If no JavaScript is needed, this does not need to be included. The `