how to import data from HTML Button from a server

I am working on a project where I need to import data from My website i.e when someone clicks a button then a string should be generated and I should import that string to a python script running on windows on a client-side. For this purpose Ive used Flask-Python but the problem is that In flask we need to create a template folder in the project folder where the python script is saved. but in my scenario, I need to run python script on windows and the template folder should be placed on the website page as I need to run HTML file on the webserver and import data from that file. I am facing this problem for a long time please someone help me.


Solution 1:

You can send the string to your route in flask. for example if you set your port in flask to 5000 so when you run it you can see in terminal the link to localhost lets say it looks like this http://195.128.1.18:5000/ and your route in flask looks like this :

@app.route('/')
def test():
    str = request.args.get('mystring', None)
    return str

and what it does it's basically shows the string you sent from html.
And your html code to send the data looks like this :

<body>
  <form target="_blank" action="http://195.128.1.18:5000/">
       Your String you want to send<input type="text" name="mystring">
       <input type="submit" value="Submit">
  </form>
</body>