安装了flask扩展

以及flask-bootstrap

默认情况下,flask在template文件夹寻找模板。

flask 加载的是Jinja2模板,该模板引擎在flask中由函数render_template集成

所以在文件中这样渲染模板

from flask import Flask,render_template
#...
@app.route('/')
def index():
return render_template('index.html') @app.route('/user/<name>')
def user(name):
return render_template('user.html', name=name)

其中:

模板中变量用双中括号{{ xxx }}表示;

控制结构是中括号加百分号{% xxx %}表示,一般是这样的

{% if %}...{% else %}...{% endif %}

{% for ...%}...{% endfor %}

flask 学习(二)的更多相关文章

  1. Flask学习 二 模板

    jinja2模版 from flask import Flask,render_template app = Flask (__name__) @app.route ('/<name>') ...

  2. flask学习(二):认识web

    url详解: URL是Uniform Resource Locator 的简写,统一资源定位符 一个URL由以下及几部分组成: scheme://host:port/path/?query-strin ...

  3. web开发框架Flask学习二

    jinja2模板规范 在当前项目中创建一个文件为templates的文件夹,将其设置为模板文件夹,新建的html为模板页面, 在视图函数中使用render_template(".html的文 ...

  4. Flask学习目录

    目录 Flask学习初识 Flask学习二

  5. Flask 学习篇二:学习Flask过程中的记录

    Flask学习笔记: GitHub上面的Flask实践项目 https://github.com/SilentCC/FlaskWeb 1.Application and Request Context ...

  6. [ZHUAN]Flask学习记录之Flask-SQLAlchemy

    From: http://www.cnblogs.com/agmcs/p/4445583.html 各种查询方式:http://www.360doc.com/content/12/0608/11/93 ...

  7. Flask学习-Wsgiref库

    一.前言 前面在Flask学习-Flask基础之WSGI中提到了WerkZeug,我们知道,WerkZeug是一个支持WSGI协议的Server,其实还有很多其他支持WSGI协议的Server.htt ...

  8. Flask学习之六 个人资料和头像

    英文博客地址:http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-vi-profile-page-and-avatars ...

  9. Flask学习之五 用户登录

    英文博客地址:http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-v-user-logins 中文翻译地址:http:// ...

随机推荐

  1. Go语言基础之Cookie和Session

    Cookie和Session Cookie和Session是Web开发绕不开的一个环节,本文介绍了Cookie和Session的原理及在Go语言中如何操作Cookie. Cookie Cookie的由 ...

  2. /build-impl.xml:1030: The module has not been deployed.(netbean javaweb)

    我在netbean上创建了一个javaweb,这个项目创建成功了,但是运行时却有了错误,错误贴图如下 报错: The module has not been deployed.  See the se ...

  3. python中的函数def和函数的参数

    '''函数: 1.减少代码重用性 2.易维护 3.可扩展性强 4.类型function 定义函数: def 函数变量名(): 函数的调用: 1.函数名加括号 2.函数如果没被调用,不会去执行函数内部的 ...

  4. 记一下拷贝windows下文件到linux下的方法

    去官网下载的Putty中包含了如下文件: 其中pscp.exe是一个远程复制文件的工具. 官网:https://www.chiark.greenend.org.uk/~sgtatham/putty/l ...

  5. 测试工具jmeter

    测试工具jmeter http:压力测试 https://www.cnblogs.com/stulzq/p/8971531.html

  6. SpringBoot使用JPA来做数据查询

    Spring-Data-JPA在做数据存储方面真的很方便,它的目的就是写更少的代码,更多的事情,但是也有其力有未逮或者说处理起来比较闹心的地方. 1.先来感受一下使用JPA做数据查询时,代码的简化程度 ...

  7. AspectJ注解支持

    <aop:aspectj-autoproxy/> 配置aspectj启动 AspectJAutoProxyBeanDefintionParser implements BeanDefini ...

  8. 寻找hive视图

    如何hive视图 1.mysql数据库 [centos@s201 ~]$ mysql -uroot -proot mysql> show databases; +---------------- ...

  9. RedisTemplate的各种操作(set、hash、list、string)

    RedisTemplate的各种操作(set.hash.list.string) 注入以下RedisTemplate @Autowired private RedisTemplate<Strin ...

  10. Spring中 bean的生命周期

    为什么要了解Spring中 bean的生命周期? 有时候我们需要自定义bean的创建过程,因此了解Spring中 bean的生命周期非常重要. 二话不说先上图: 在谈具体流程之前先看看Spring官方 ...