Thank you for your answers so far.
I'd like to focus my intention for clarification:
I have a HTML site with a form to pick a a number that the user has to type in.
Now, I'd like to know what the Python code (on the server) is to simply receive this
number and put it into a value called "number".
This intention is very simple, but I want to know how it works.
Thanks again!
(Mar-15-2017, 01:21 PM)c0da Wrote: [ -> ]I have a HTML site with a form to pick a a number that the user has to type in.
I'd like to focus my intention for clarification:
Now, I'd like to know what the Python code (on the server) is to simply receive this
number and put it into a value called "number".
What language and server are you running?
When you have a html form and a number get submit,
it's send data to server and you process it there(if eg sever run PHP you get vaule with
number = $_POST['data from form']
)
If eg run Python(Flask) as server i get data with
number = request.form['data from form']
When looking at this from outside(no server access) can use
Requests to make post requests.
import requests
url = "http://127.0.0.1:5000/" # Eg my local Flask server
# Construct POST request
form_data = {
'my-form' : "Send",
'text' : 5
}
post = requests.post(url, data=form_data)
number = post.text
print(number) #--> 5
So i am doing a POST requests on this html code.
<!DOCTYPE html>
<html>
<body>
<form action="." method="POST">
<input type="text" name="text">
<input type="submit" name="my-form" value="Send">
</form>
</body>
</html>