data passing app in falcon python

*爱你&永不变心* 提交于 2019-12-05 17:56:19

Here is a working example!

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <form action="http://127.0.0.1:8000" method="post">
        <input type="text" name="name">
        <button type="submit" name="btn">Submit</button>
    </form>
</body>
</html>

Falcon code:

import falcon
from wsgiref import simple_server

class Resource(object):
    def on_post(self, req, resp):
        resp.status = falcon.HTTP_200
        resp.body = req.params['name']

app = api = falcon.API()
app.req_options.auto_parse_form_urlencoded = True
api.add_route('/', Resource())

if __name__ == '__main__':
    http = simple_server.make_server('127.0.0.1', 8000, app)
    http.serve_forever()
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!