首页 > 解决方案 > Flask 请求错误

问题描述

尝试使用 Flask 从 Pythonanywhere(付费帐户)上的 Web 应用程序发出请求。这在本地 PC 上根据需要工作,但在 Pythonanywhere 上收到错误。

@app.route('/test/')
def test():
 url_cookies='https://www.phoenixcontact.com/online/portal/ru/pxc/offcontext/'
 headers = {'authority': 'www.phoenixcontact.com',  'method': 'GET','user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36'}
 requestCookies = requests.get(url_cookies,headers=headers)
 return 'Test'+requestCookies.text

标签: pythonanywhere

解决方案


pythonanywhere有一个只允许使用免费版本废弃的有限网页。您可以通过升级到其高级计划之一来消除此限制。

您可以考虑使用OpenShift 之类的FreeHosts来托管您的应用程序。


推荐阅读