0

When I run my app from cmd, I'm able to call the api very quickly. But when it is hosted in IIS (fastcgi - wfastcgi.py) the run takes forever and I"m unable to get any return from the api.

import flask

app = flask.Flask(__name__)
app.config["DEBUG"] = True
app.config['UPLOAD_FOLDER'] = 'holding'

@app.route('/test', methods=['GET', 'POST'])
def test():
    import subprocess
    import os
    import re

    libreoffice_exe = 'C:/Program Files/LibreOffice/program/soffice'
    inputFileName = r'D:\folder\some_powerpoint_file.pptx'
    outputFileName = r'D:\folder\output.pdf'

    inputFileName = re.sub('\\\\', '/', inputFileName)
    outputFileName = re.sub('\\\\', '/', outputFileName)

    outputFileDir = os.path.dirname(outputFileName)
    call_item = [libreoffice_exe, '--headless', '--convert-to', 'pdf', inputFileName, '--outdir', outputFileDir]
    proc = subprocess.Popen(
        call_item, 
        stdout=subprocess.PIPE, 
        stderr=subprocess.PIPE
    )
    proc.wait()
    (stdout, stderr) = proc.communicate()
    if proc.returncode != 0:
        print(str(stdout))
        print(str(stderr))
        return 'fail'

    return 'success'

if __name__ == '__main__':
    app.run()

I'm not getting any error output from stderr/stdout.. it just runs indefinitely (until timeout)

1 Answer 1

0

Hope this will resolve another person's problem..

This helped me: https://ask.libreoffice.org/en/question/182108/not-able-to-launch-soffice-within-an-application-on-the-iis-server/

What worked for me is to add the argument into the subprocess call: "-env:UserInstallation=[file:///C:/test/NPP]" where [file:///C:/test/NPP] can be any url i believe

call_item = [libreoffice_exe, '-env:UserInstallation=file:///C:/test', '--headless', '--convert-to', 'pdf', inputFileName, '--outdir', outputFileDir]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.