DesktopApp.get_request#

static DesktopApp.get_request()#

A static method that gets data sent from client using HTTP request.

This method returns the request object of Flask. The request object has some useful attributes such as request.files which retrieves uploaded files.

Examples

To use this method, first create the app and a page:

>>> app = Website(__name__, secret_key="some key")
>>> home_page = Page(html_str="""<form method="post" enctype="multipart/form-data">
...                              <input type="file" name="filename">
...                              <input type="submit">
...                              </form>""", url="/")

Then create a function that will be called when an HTTP request is made:

>>> def request_function():
...     request = app.get_request()
...     print(request.files)

Now add the function to Page.on_url_request() method:

>>> home_page.on_url_request(request_function)

Add the page to the app and run the app:

>>> app.add_pages(home_page)
>>> if __name__ == "__main__":
...     app.run() 
Return type:

flask.request

See also

flask.request

https

//flask.palletsprojects.com/en/2.2.x/api/#flask.request

Page.on_url_request