Information Passing between your Frontend and Backend (PART ONE).

PURPOSE

To pass dynamic information from the front end to the server [HTML Forms Parsing]

The Author assumes that you have basic understanding of integrating HTML with Flask.

Sending Information from Frontend HTML to your Python Server Script.

HTML

To pass data from Frontend we need to POST it. Forms provide a way to do so.

Modify your index.html so that it contains a basic form:

Python/Flask

To receive data from the frontend we need to create an endpoint that accepts POST requests.

Modify your main app.py file like so:

Run the app.py file:

  • Now, visit localhost:5000 on your browser, you will see the form just created in index.html
  • Fill up the information and hit the submit button.
  • Rejoice at your creation!

Next Blog: Information Passing between your Frontend and Backend (PART TWO).

Thank the author. Fork this blog.


Tagged in flask