title: How to execute a python script from html form and return result
body: <p>I have a website with a form allowing users to upload files ( pdf or docx ). I'm trying to execute some python code on the file loaded and return and print the text of the file on the HTML page. </p>
  
  <p>After some research, I understood that :</p>
  
  <ul>
  <li><p>we call the python script thanks to the html form. This call execute the python script which receives the data throught the post method </p></li>
  <li><p>The python script does his job and return html code with the result.</p></li>
  </ul>
  
  <p>For the html part : </p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
    &lt;h1&gt;Upload File&lt;/h1&gt;
    &lt;form action="example.py" method="POST" enctype="multipart/form-data"&gt;
        File: &lt;input name="file" type="file"&gt;
        &lt;input name="submit" type="submit"&gt;
    &lt;/form&gt; 
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>For the python part :</p>
  
  <pre><code>def convert_doc_to_text(filename):
      text = textract.process(filename) # extract text from file 
      return text.decode('utf-8')
  </code></pre>
  
  <ul>
  <li>With which technology would I be able to host and execute the python script ?</li>
  <li>How could I transfer the file uploaded between the website server and the python script server ? </li>
  </ul>
  
  <p>Thanks in advance.</p>