title: Python long polling server (same as existing PHP server)
body: <p>I have a simple php script (that runs on xampp) for long polling server, but I would like to translate it to Python and make it a Python server. I'm kind off inexperienced with python (specially when it comes to web servers) and I haven't found any simple solutions for Python web servers that would do this same thing so I'm wondering, could anyone help me translating this script from php to Python.</p>
  
  <p>My php script does this: it GETs timestamp from the client and then keeps comparing it to current modification time of file, and if they are different, it sends contents of file and new timestamp coded in JSON.
  Here is my code:</p>
  
  <pre><code>&lt;?php
  $filename = dirname(__FILE__).'/data.txt';
  
  $lastmodif = isset($_GET['timestamp']) ? $_GET['timestamp'] : 0;
  $currentmodif = filemtime($filename);
  
  while ($currentmodif &lt;= $lastmodif){
      usleep(10000);
      clearstatcache();
      $currentmodif = filemtime($filename);
  }
  
  $response = array();
  $response['msg'] = file_get_contents($filename);
  $response['timestamp'] = $currentmodif;
  echo json_encode($response);
  ?&gt;
  </code></pre>