Webpy AttributeError 'header 键'

Webpy AttributeError ' header key'

我最近在我的 ubuntu 机器上下载了 webpy,但我目前在使用它的 POST 功能时遇到了问题。 这是我的代码:

#! /usr/bin/env python

import web,interface

urls = (
    '/', 'index'
)

class index(object):
    def POST(self):
        data = web.input()
        interface.interfaceModule(data.decider)
    return "SENT TO INTERFACE"


if __name__ == "__main__":
    app = web.application(urls, globals())
    app.run()

接口只是另一个 class 接收 POST 值,并通过串行将其发送到 Arduino。

这是错误输出:

 Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/web/application.py", line     239, in process
return self.handle()
File "/usr/local/lib/python2.7/dist-packages/web/application.py", line 230, in handle
    return self._delegate(fn, self.fvars, args)
File "/usr/local/lib/python2.7/dist-packages/web/application.py", line 462,    in _delegate
   return handle_class(cls)
  File "/usr/local/lib/python2.7/dist-packages/web/application.py", line 438, in handle_class
    return tocall(*args)
  File "/var/www/cgi-bin/index.py", line 12, in POST
    interface.interfaceModule(data.decider)
  File "/usr/local/lib/python2.7/dist-packages/web/utils.py", line 76, in _  _getattr__
    raise AttributeError, k
AttributeError: 'decider'

192.168.10.1:52225 - - [09/Dec/2016 19:41:09] "HTTP/1.1 POST /" - 500   Internal Server Error

我使用 Chromium 应用发送了 post 请求:POST-MAN,带有指定的键和任意值。

此错误意味着您发送了错误的请求 - 您没有在 POST.

中发送 decider

尝试

import requests

r = requests.post('http://localhost:8080', data={'decider':'Hello World'})

print(r.text)