首页 > 解决方案 > 如何在 url 中传递字典类型对象?

问题描述

我正在学习烧瓶。我尝试使用 request.args.get()。我对如何制作包含字典对象的 url 请求感到困惑

这是我的代码。我想向 /hello 发送 e url 请求,例如 "text":"Hello World"

@app.route("/hello")
def hello():
    text = request.args.get("text",default="Hello World",type=str)
    return text

标签: pythonflask

解决方案


假设您尝试从浏览器访问此端点,并传递一个文本参数,请尝试如下 URL:

http://127.0.0.1:5000/hello?text=Fahad

推荐阅读