1

たとえば、POST でhttp://localhost:8080/?var=valなどにアクセスしたいのですが、500 サーバー エラーが発生します。

500内部サーバーエラー

サーバーで予期しない状況が発生したため、要求を実行できませんでした。

トレースバック (最新の呼び出しが最後):
 ファイル「c:\python26\lib\site-packages\cherrypy\_cprequest.py」、606行目、応答
   cherrypy.response.body = self.handler()
 ファイル「c:\python26\lib\site-packages\cherrypy\_cpdispatch.py​​」、25 行目、__call__ 内
   return self.callable(*self.args, **self.kwargs)
TypeError: index() は引数を取りません (1 つ指定)

CherryPy 3.1.2 を搭載

4

1 に答える 1

1

それは間違いなく可能です。

以下に例を示します ( CherryPy チュートリアルから適応):

<form action="indexPostHandler" method="post">
    <p>Enter a value:</p>
    <input type="text" name="val" value=""/>
    <p><input type="submit" value="Login"/></p>
</form>

また、インデックスでは、次のようなものを使用してリクエストを処理できます。

class Root:
    # create form here
    def indexPostHandler(self, val=None):
        # do something with val here
        ...
于 2010-01-03T01:25:21.483 に答える