JZTXT
  • 首页
  • Ai
  • Java
  • Python
  • Android
  • Mysql
  • JavaScript
  • Html
  • CSS

Flask008_构造 URL

发布时间 2023-05-26 10:52:50作者: jason2018
  • 通过 url_for 函数构造 URL。
  • url_for 接收视图函数名作为第1个参数,以及其他 URL 定义时的参数,其他参数添加到 URL 的后面作为查询字符串参数。
1 @app.route('/blog/<int:blog_id>')
2 def blog_detail(blog_id):
3     return f"您查找的博客 id为{blog_id}"
4 
5 
6 @app.route("/urlfor")
7 def get_url_for():
8     url = url_for('blog_detail', blog_id=2, user="admin")
9     return url

 

    本栏目推荐文章
  • 手把手教你MongoDB 数据库连接URL 格式、authSource参数
  • web项目启动时dubbo报错: No provider available for the service com.davidhu.shopguide.api.service.UserEventService from the url zookeeper ://localhost:2181/org.apache.du
  • 微信小程序或js中获取url参数
  • Flask开放的端口不能访问的解决方案
  • flask 中使用 wtforms 验证请求数据的方式
  • Python Flask 特殊装饰器,执行路由前和执行路由后执行的装饰器
  • SpringBoot配置报错:Description: Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured. Reason: Failed to determine a suitable driver class
  • Python Flask 返回函数 、带值的函数
  • Python Flask html 模板的继承
  • asp.net mvc2中controller的action无法获取url中过来bool类型参数
版权声明:本网站为非赢利性站点,本网站所有内容均来源于互联网相关站点自动搜索采集信息,相关链接已经注明来源。
联系我们