Windows Azure Web sites python

≡放荡痞女 提交于 2019-12-23 12:33:55

问题


After a whole load of hard work I've eventually got a hello world flask app running on Windows Azure, the app is built locally and runs fine, deploying it to Azure is a nightmare though. So I've sort of got two questions here.

I can't seem to get a stack trace at all, I've tried setting things in web.config, but the documentation on how to use all this stuff is just apawling, all I can find is just literally badly written blog posts dotted around one of microsoft's millions of blogs. Which doesn't even help me to fix my problem.

The second question relates to the first one, due to some horrible debugging methods (taking my application apart and commenting things out) I feel like it could be pymongo causing this, I've built it without the C extensions and it's in my site-packages and it works on my local machine. However without a stack trace I've just no idea how to fix this without wanting to pull my hair out.

Can anyone shed some light on this? Really disappointing because the rest of azure isn't too bad, theres far better website hosting alternatives out there like heroku which are literally 10 command setups. I've been working on this all day so far..


回答1:


Solved

For those who are interested I ended up solving this problem my manually adding error handling into my flask application completely bypassing the IIS settings and windows azure configs - far too complicated with no documentation at all.

from werkzeug.debug import get_current_traceback   

@app.errorhandler(500)
def internal_server_error(e):
    base = os.path.dirname(os.path.abspath(__file__))
    f = open('%s/logs/error.log' % (base), 'a')
    track = get_current_traceback(skip=1, show_hidden_frames=True, ignore_system_exceptions=False)
    track.log(f)
    f.close()

    return 'An error has occured', 500


来源:https://stackoverflow.com/questions/15160772/windows-azure-web-sites-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!