1.Flask中的HTTPResponse

在Flask 中的HttpResponse 在我们看来其实就是直接返回字符串

2.Flask中的Redirect

每当访问"/redi"这个地址的时候,视图函数redi会触发redirect("/") 跳转到url地址:  "/" 并会触发"/"对应的视图函数index()

3.Flask 中的 render (render_template)

HTML模板渲染是每个Web框架中都必须有的,至于render_template的具体用法,留个悬念,往后看

注意: 如果要使用 render_template 返回渲染的模板,请在项目的主目录中加入一个目录 templates

否则可能会有一个Jinja2的异常哦

遇到上述的问题,基本上就是你的template的路径问题

4.打开并返回文件内容 send_file("文件的路径")

5.标准JSON格式的Response jsonify({name:1}) # Content-type:application/json

Flask 中的 5种返回值的更多相关文章

  1. 慕课网-Java入门第一季-7-3 Java 中无参带返回值方法的使用

    来源:http://www.imooc.com/code/1579 如果方法不包含参数,但有返回值,我们称为无参带返回值的方法. 例如:下面的代码,定义了一个方法名为 calSum ,无参数,但返回值 ...

  2. Java 中无参带返回值方法的使用

    如果方法不包含参数,但有返回值,我们称为无参带返回值的方法. 例如:下面的代码,定义了一个方法名为 calSum ,无参数,但返回值为 int 类型的方法,执行的操作为计算两数之和,并返回结果 在 c ...

  3. python中os.system()的返回值

    [python中os.system()的返回值] 如果第三方程序返回的是布尔型返回值,os.system会将true转为1,false转为0进行返回. 问题: /bin/xxx.py是一个返回码为1的 ...

  4. SpringMVC中controller的几种返回值

    String :跳转到对应的返回值中. return “/index”: ModelAndView: 控制页面跳转方式: 1. ModelAndView modelAndView = new Mode ...

  5. [转] C++中临时对象及返回值优化

    http://www.cnblogs.com/xkfz007/articles/2506022.html 什么是临时对象? C++真正的临时对象是不可见的匿名对象,不会出现在你的源码中,但是程序在运行 ...

  6. SSM-SpringMVC-20:SpringMVC中处理器方法之返回值void篇

      ------------吾亦无他,唯手熟尔,谦卑若愚,好学若饥------------- 处理器的方法我们之前做过,返回值为String的,返回值为ModelAndView的,我们这个讲的这个返回 ...

  7. STL中的容器作为返回值

    分别以函数返回值方式和参数传引用方式测试了vector.map两种容器,代码如下: // testContainer.cpp : Defines the entry point for the con ...

  8. 转:C++中临时对象及返回值优化

    http://www.cnblogs.com/xkfz007/articles/2506022.html 什么是临时对象? C++真正的临时对象是不可见的匿名对象,不会出现在你的源码中,但是程序在运行 ...

  9. JAVA IO中read()方法的返回值

    read()方法的作用是从输入流读取数据的下一个字节,返回的字节的值是一个0~255之间的整数.到达流的末尾返回-1. 刚开始我以为这个返回值表示的是所读取的数据的长度,可是之后在一个示例程序中发现这 ...

随机推荐

  1. playbook

    1 --- - hosts: web-server 3 remote_user: root tasks: - name: stop logstash shell: PID=` $PID &&a ...

  2. python入门(七):字符串

    1.字符串类型: >>> s="早上好"               #str类型的字符串 >>> type(s) <class 'str ...

  3. Vue watch的高级用法

    <div> <p>FullName: {{fullName}}</p> <p>FirstName: <input type="text& ...

  4. JAVA获取系统信息以及系统时间

    在做测试的时候,经常需要获取系统信息,并且用获取到的系统时间给生成的报告取名字. 以下代码实在TestNG展示的,没有Test NG的话需要些一个main方法. import java.net.Ine ...

  5. 浏览器useragent

    var ua = window.navigator.userAgent; edge :Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537 ...

  6. gitlab 备份与恢复

    1. gitlab 备份命令:# gitlab-rake gitlab:backup:create 1.1 查看备份文件(默认备份路径:/var/opt/gitlab/backups)# ls /va ...

  7. 绑定checkedComboBox

    using System; namespace CommonLib{ /// <summary> /// CommonCode 的摘要说明. /// </summary> [S ...

  8. [leetcode]170. Two Sum III - Data structure design两数之和III - 数据结构设计

    Design and implement a TwoSum class. It should support the following operations: add and find. add - ...

  9. canvas(一) 基本线条绘制

    var dom = document.getElementById('canvasItem'), ctx = dom.getContext('2d'); //坐标位置默认基于 浏览器窗口(0,0),此 ...

  10. Silverlight实用窍门系列:68.Silverlight的资源字典ResourceDictionary

      允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://chengxingliang.blog.51cto.com/3972944/886643 ...