'Using pypandoc on IIS server
After testing our Flask api on our local system, I have been unable to run the same app after deploying on IIS server. Basically it gives me 500 error whenever I use pypandoc, but when I remove it app works. You can consider the following simple snippet with pypandoc :
from flask import Flask
app = Flask(__name__)
import os
import pypandoc
#path= pypandoc.get_pandoc_path()
os.environ.setdefault('PYPANDOC_PANDOC','C:\\Pandoc\\pandoc.exe')
@app.route("/")
def home():
note =*** any html string ***
rtf_string = pypandoc.convert_text(note, 'rtf', format='html')
return rtf_string
if __name__ == "__main__":
app.run()
Earlier I was getting the following error before setting 'PYPANDOC_PANDOC'
{"message": "Failed to Insert Data. No pandoc was found: either install pandoc and add it to your PATH or or call pypandoc.download_pandoc(...) or install pypandoc wheels with included pandoc.", "status": 0}
But I followed the following links and that error went away : Flask cannot find Pandoc on Linux Server (nginx+uwsgi)
Now I get the following error page : enter image description here
Solution 1:[1]
Basically what was found is that after deploying on the IIS server pypandoc was simply unable to locate pandoc.exe file. This was not the case while testing locally. I got rid of pypandoc library altogether, and used python subprocess to access pandoc.exe directly. But still RTF to HTML conversion is kinda lossy with Pandoc. If the RTF file has complicated data such tables and images then it all gets lost or distorted.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | GauravKB |