So here it goes, I am developing a game that can be controlled via wi-fi. I was planning on modifying a file via a PhP webserver, this file is later read by a Python program in a constant loop detecting updates. So at a given moment both the python program and the webserver will open the same file, so there goes my question...
This is basically the Python code that i will use:
file = open('file.ext', 'r')
answer = file.readline()
file.close()
And the PhP Code:
$dir = $_POST['dir'];
$file = fopen('file.ext', 'w+');
switch ($dir) {
case 'up':
fwrite($file, 'up');
break;
case 'down':
fwrite($file, 'down');
break;
case 'left':
fwrite($file, 'left');
break;
case 'right':
fwrite($file, 'right');
break;
}
fclose($file);