POST請求我有一個非常簡單的扭曲的腳本,你可以處理POST請求:如何處理扭曲
class FormPage(Resource):
isLeaf = True
def render_GET(self, request):
return b"""<html><body><form method="POST"><input name="form-field" type="text" /></form></body></html>"""
def render_POST(self, request):
return '<html><body>You submitted: %s</body></html>' % (cgi.escape(request.args["form-field"][0]),)
factory = Site(FormPage())
reactor.listenTCP(80, factory)
reactor.run()
但每當我跑這一點,並填寫框,我得到和錯誤:
builtins.KeyError: 'form-field'
有人能告訴我這是爲什麼嗎?謝謝!!