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.
After some research, I understood that :
we call the python script thanks to the html form. This call execute the python script which receives the data throught the post method
The python script does his job and return html code with the result.
For the html part :
<html>
<head>
<title></title>
</head>
<body>
<h1>Upload File</h1>
<form action="example.py" method="POST" enctype="multipart/form-data">
File: <input name="file" type="file">
<input name="submit" type="submit">
</form>
</body>
</html>
For the python part :
def convert_doc_to_text(filename):
text = textract.process(filename) # extract text from file
return text.decode('utf-8')
- With which technology would I be able to host and execute the python script ?
- How could I transfer the file uploaded between the website server and the python script server ?
Thanks in advance.