Publishing Flask Web App on Azure

后端 未结 2 1460
失恋的感觉
失恋的感觉 2020-12-20 10:11

I have Flask web app that im trying to publish on azure. I deployed it on web app, Created new resource, downloaded user publish profile and published it from visual studio

相关标签:
2条回答
  • 2020-12-20 10:32

    Per my experience, there are many reasons which will cause the issue like yours.

    For the first case, some Python packages required in the reqirements.txt file are not directly installed on Azure WebApp. For this case, you need to follow the offical toturial for troubleshooting to solve it. Or even, you can try to follow my solution for the other SO thread Publishing MVC app that uses python script to solve it.

    However, I think your issue might be caused by the senna_path in your code is not a valid path on Azure WebApp. I tried to create a simple Python script as below to test your code using Kudu console on Azure WebApp, it works fine via command python test.py > test.out.txt.

    import os
    from subprocess import Popen, PIPE
    
    path = os.path.join('senna-win32.exe')
    p = Popen(path, stdin=PIPE, stdout=PIPE)
    grep_stdout = p.communicate(input="happy time".encode('utf-8'))[0]
    inList = grep_stdout.decode()
    inList = list(inList.splitlines())
    print inList
    

    So my suggestion is that try to use the absolute path D:\home\site\wwwroot\FlaskWebProject1\senna\senna-win32.exe instead of senna\senna-win32.exe for your app to solve the issue.

    Any update, please feel free to let me know.

    0 讨论(0)
  • 2020-12-20 10:34

    I had the same issue, in my case the problem was missing redirection of the stderr, same as your code I redirected only stdout+stdin.

    Adding stderr=PIPE solved my problem.

    process = Popen(exe_relative_path, stdin=PIPE, stdout=PIPE, stderr=PIPE)  
    
    0 讨论(0)
提交回复
热议问题