-1
Flask를 사용하여 Restful 웹 서비스를 만들려고합니다. 하지만 GET 요청에서 xml 데이터를 처리하는 데 문제가 있습니다.Flask : GET 메서드에서 XML 처리
uri="http://127.0.0.1:5000/test/api/getfamilyinfo"
request_body='''
<StayInfo>
<district>Khurda</district>
<village>BBSR</village>
<unit>Hogwarts</unit>
</StayInfo>
'''
body_format = {'Content-Type': 'application/xml'}
requests.get(uri, data = request_body, verify = False, headers = body_format)
나는 점점 오전 오류 :
File "C:\Python27\lib\xml\etree\ElementTree.py", line 647, in parse
source = open(source, "rb")
TypeError: coercing to Unicode: need string or buffer, Response found</textarea>
내 코드 :
@app.route('/test/api/getfamilyinfo', methods=['GET'])
def getfamilyinfo():
errors = []
results = {}
if request.method == "GET":
try:
r=request.data
except Exception,e:
resp = jsonify({"error": str(e)})
return resp, status.HTTP_400_BAD_REQUEST
if r:
eTree = ElementTree.parse(r) ## The code is breaking here
가 친절하게 내가 잘못 가고 어디에 이해하는 데 도움이. 미리 감사드립니다.
감사합니다. 알았다. 그것의 일 벌금. – May