python - 烧瓶 api 没有返回 xml
问题描述
我不能让我的 Flask API 返回 XML。
我在错误日志中没有收到任何错误,但这是来自服务器日志:
2020-06-10 21:14:01 [Errno 2] No such file or directory: '<bound method Response.json of <Response [200]>>'
2020-06-10 21:14:01 [Errno 2] No such file or directory: '<bound method Response.json of <Response [200]>>'
2020-06-10 21:14:02 DAMN ! worker 1 (pid: 2) died :( trying respawn ...
2020-06-10 21:14:02 Respawned uWSGI worker 1 (new pid: 13)
2020-06-10 21:14:02 spawned 2 offload threads for uWSGI worker 1
从 pythonanywhere 我得到这个消息:
出问题了 :-(
<p>
This website is hosted by PythonAnywhere, an online hosting
environment. Something went wrong while trying to load it;
please try again later.
</p>
<div class="for-site-owner">
<h2>Debugging tips</h2>
<p>
If this is your PythonAnywhere-hosted site, and you just reloaded
it, then the problem might simply be that it hasn't loaded up yet.
Try refreshing this page and see if this message disappears.
</p>
<p>
If you keep getting this message, you should check your site's
server and error logs for any messages — you can view them
from the Web tab inside PythonAnywhere.
</p>
<p>
If there's nothing in the logs, and you're sure your site is OK,
then it might be a problem on our side. Drop us a line at
support@pythonanywhere.com, in the forums, or using the "Send
feedback" link on the site, quoting the error code below.
</p>
</div>
<p>
Error code: 502-backend
这是我的代码:
r = requests.request("GET", url, headers=headers)
# get the xml from a json string
if r.status_code == 200:
js_data = str(r.json)
xml_data = readfromjson(js_data)
return json2xml.Json2xml(xml_data).to_xml()
我可以返回 js_data 没问题
BR克雷斯顿
解决方案
推荐阅读
- html - 输入文本框不适应窗口大小
- html - 在 FullCalendar 上选择日期时,点击精度校准错误
- node.js - 纱线 2 - YN0027:react@unknown 无法解析到令人满意的范围:
- java - Android Studio - 在 Y 坐标上获取屏幕底部的 5th
- c# - 向数据库表添加新记录时出现异常未处理
- javascript - 他们不会加载 glider-js 在 nextjs 中创建的 div 内的元素
- java - 我正在制作一个程序来模拟战争游戏,但是在尝试获取随机卡片时,我总是随机出现错误
- javascript - 如何使用 puppeteer 单击列表中的特定元素?
- next.js - Next.js - 不同的获取类型方法
- c++ - 显式构造函数不是候选者