werkzeug实现简单

我怕爱的太早我们不能终老 提交于 2020-03-11 13:55:05

werkzeug实现简单

1.通过request请求获取name值

code代码为

from werkzeug.wrappers import Request, Response


def application(environ, start_response):
    request = Request(environ)
    text = 'Hello %s!' % request.args.get('name', 'Keny88888')
    response = Response(text, mimetype='text/plain')
    return response(environ, start_response)

if __name__ == "__main__":
    from werkzeug.serving import run_simple
    run_simple("localhost", 5000, application)

2.运行结果

2.1直接请求为http://localhost:5000/

默认为Hello Keny88888 

2.2 赋值为name为=88888888

http://localhost:5000/?name=88888888

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!