Question about parsing a URL generated during a button click event in HTML

Viewed 19

I built a form in HTML5 to take input from users. I'm using the GET method. I want to assign the data the user put into the form and assign it to variables in a python script, which will do some logic then render another page at the end of the script which will present the data to the user.

I have been researching the past day or so about different methods by which this can happen. I'm running on Django right now.

I was going to use CGI, because the syntax seemed pretty straightforward:

import cgi

form = cgi.FieldStorage()

py_var = form.getvalue('name-in-html-tag')

But from what I've read is that this method is only suitable for cgi scripts. When I print() py_var I continually get a value of None.

So I started reading about using the urllib package to parse GET method urls. But the examples I keep finding online show the URL hardcoded into the scripts, which isn't much help in my situation.

Is there a way that I can get the URL generated from the GET method so that I can parse it and use the data in a python script?

Everyone seems to have their own way of doing this, so that makes it a little difficult to piece it all together.

I've looked through some yt tutorials for Django, but the problem is that all of the videos tend to start from the mindset that the dev wants to create and store information in a db. I don't want to store or save any information from users. I want to process it through a py script and present the new data afterwards.

Maybe there's a flaw in my idea of how this should be done?

  1. Render HTML webpage for user to input data
  2. Use button submit even to generate a URL
  3. Parse generated URL and assign data to variables in py script
  4. Render HTML webpage with output for user to see

The next foreseen issue I might have is between steps 3 and 4. Will I inevitably have to create db's to act as middlemen between this data?

0 Answers
Related