0

I'm currently trying to grab a string that a user would put in an HTML form, and set that equal to a variable in a python program after the 'search' button has been clicked. I'm using flask to run the html code just on localhost. How would I go about implementing this?

The code I have for the search bar so far is below.

      <div class="input-group pl-2">
        <input type="text" class="form-control" placeholder="Enter a string...">         
          <span class="input-group-btn pr-2">
            <button class="btn btn-success" type="submit">
              <span></span>Search
            </button>
          </span>
      </div>
Julison
  • 11
  • 5
  • 1
    Do you have something on the server side, a web server, some python code which generates this, or is this all you have? – zvone Dec 02 '19 at 23:07
  • 1
    Take a look at this: https://stackoverflow.com/questions/48552343/how-can-i-execute-a-python-script-from-an-html-button. What you are trying to do is execute some action (in this case assign a value to some variable) when the submit button is clicked. So you need to fire a function that will do this when the submit button is clicked. The thread I shared has a smilar example. I hope it helps. – CypherX Dec 02 '19 at 23:07
  • @zvone I'm using flask and running on localhost – Julison Dec 02 '19 at 23:13

0 Answers0