Website#
- class toui.apps.Website(name=None, assets_folder=None, secret_key=None)[source]#
Bases:
_AppA class that create a web application from HTML files.
- flask_app#
ToUI creates web applications using Flask. You can access the Flask object using the attribute flask_app.
- Type:
Flask
- forbidden_urls#
These are URLs that ToUI does not allow the user to use because ToUI uses them.
- Type:
list
- user_vars#
A dictionary that stores data unique to each user. The data are stored in flask session object.
- Type:
dict
- pages#
A list of added Page objects.
- Type:
list
Examples
Creating a web app:
>>> from toui import Website >>> app = Website(__name__, secret_key="some key")
Creating a page and adding it to the app:
>>> from toui import Page >>> home_page = Page(html_str="<h1>This is the home page</h1>") >>> app.add_pages(home_page)
Running the app:
>>> if __name__ == "__main__": ... app.run(debug=True)
See also
- Parameters:
name (str (optional)) – The name of the app.
assets_folder (str (optional)) – The path to the folder that contains the HTML files and other assets.
secret_key (str (optional)) – Sets the secret_key attribute for flask.Flask
Methods#
Adds pages to the app. |
|
Returns the current Page. |
|
Redirects to another URL. |
|
Registers a ToUIBlueprint object. |
|
Runs the app. |
|
Validate data received from JavaScript before using it. |
|
Makes the app private. |
|
Validate simple_websocket.ws.Server object before sending and accepting data. |