I`m trying to communicate between my website and a client side script. The Python client sends a POST to a PHP file, which then prints it to show me that the POST is working, so I can move on to the next step of my development. However, for some reason, I can only post to it with an HTML5 form, and not Python 3.5.2 requests module.
This is the PHP:
<?php
$data = ((!empty($_POST['data'])) ? $_POST['data'] : 'N/A');
echo $data;
?>
The Python:
>>> import requests
>>> url = "www.example.com/coords.php"
>>> data = "This is a string"
>>> r = requests.post(url, data)
>>> r.content
b'N/A'
The HTML5 that works:
<html>
<head>
</head>
<body>
<form method="post" action="www.example.com/coords.php">
<input type="text" name="data">
<input type="submit" name="submit">
</form>
</body>
</html>