MarkdownPad Document

*:first-child {
margin-top: 0 !important;
}

body>*:last-child {
margin-bottom: 0 !important;
}

/* BLOCKS
=============================================================================*/

p, blockquote, ul, ol, dl, table, pre {
margin: 15px 0;
}

/* HEADERS
=============================================================================*/

h1, h2, h3, h4, h5, h6 {
margin: 20px 0 10px;
padding: 0;
font-weight: bold;
-webkit-font-smoothing: antialiased;
}

h1 tt, h1 code, h2 tt, h2 code, h3 tt, h3 code, h4 tt, h4 code, h5 tt, h5 code, h6 tt, h6 code {
font-size: inherit;
}

h1 {
font-size: 28px;
color: #000;
}

h2 {
font-size: 24px;
border-bottom: 1px solid #ccc;
color: #000;
}

h3 {
font-size: 18px;
}

h4 {
font-size: 16px;
}

h5 {
font-size: 14px;
}

h6 {
color: #777;
font-size: 14px;
}

body>h2:first-child, body>h1:first-child, body>h1:first-child+h2, body>h3:first-child, body>h4:first-child, body>h5:first-child, body>h6:first-child {
margin-top: 0;
padding-top: 0;
}

a:first-child h1, a:first-child h2, a:first-child h3, a:first-child h4, a:first-child h5, a:first-child h6 {
margin-top: 0;
padding-top: 0;
}

h1+p, h2+p, h3+p, h4+p, h5+p, h6+p {
margin-top: 10px;
}

/* LINKS
=============================================================================*/

a {
color: #4183C4;
text-decoration: none;
}

a:hover {
text-decoration: underline;
}

/* LISTS
=============================================================================*/

ul, ol {
padding-left: 30px;
}

ul li > :first-child,
ol li > :first-child,
ul li ul:first-of-type,
ol li ol:first-of-type,
ul li ol:first-of-type,
ol li ul:first-of-type {
margin-top: 0px;
}

ul ul, ul ol, ol ol, ol ul {
margin-bottom: 0;
}

dl {
padding: 0;
}

dl dt {
font-size: 14px;
font-weight: bold;
font-style: italic;
padding: 0;
margin: 15px 0 5px;
}

dl dt:first-child {
padding: 0;
}

dl dt>:first-child {
margin-top: 0px;
}

dl dt>:last-child {
margin-bottom: 0px;
}

dl dd {
margin: 0 0 15px;
padding: 0 15px;
}

dl dd>:first-child {
margin-top: 0px;
}

dl dd>:last-child {
margin-bottom: 0px;
}

/* CODE
=============================================================================*/

pre, code, tt {
font-size: 12px;
font-family: Consolas, "Liberation Mono", Courier, monospace;
}

code, tt {
margin: 0 0px;
padding: 0px 0px;
white-space: nowrap;
border: 1px solid #eaeaea;
background-color: #f8f8f8;
border-radius: 3px;
}

pre>code {
margin: 0;
padding: 0;
white-space: pre;
border: none;
background: transparent;
}

pre {
background-color: #f8f8f8;
border: 1px solid #ccc;
font-size: 13px;
line-height: 19px;
overflow: auto;
padding: 6px 10px;
border-radius: 3px;
}

pre code, pre tt {
background-color: transparent;
border: none;
}

kbd {
-moz-border-bottom-colors: none;
-moz-border-left-colors: none;
-moz-border-right-colors: none;
-moz-border-top-colors: none;
background-color: #DDDDDD;
background-image: linear-gradient(#F1F1F1, #DDDDDD);
background-repeat: repeat-x;
border-color: #DDDDDD #CCCCCC #CCCCCC #DDDDDD;
border-image: none;
border-radius: 2px 2px 2px 2px;
border-style: solid;
border-width: 1px;
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
line-height: 10px;
padding: 1px 4px;
}

/* QUOTES
=============================================================================*/

blockquote {
border-left: 4px solid #DDD;
padding: 0 15px;
color: #777;
}

blockquote>:first-child {
margin-top: 0px;
}

blockquote>:last-child {
margin-bottom: 0px;
}

/* HORIZONTAL RULES
=============================================================================*/

hr {
clear: both;
margin: 15px 0;
height: 0px;
overflow: hidden;
border: none;
background: transparent;
border-bottom: 4px solid #ddd;
padding: 0;
}

/* TABLES
=============================================================================*/

table th {
font-weight: bold;
}

table th, table td {
border: 1px solid #ccc;
padding: 6px 13px;
}

table tr {
border-top: 1px solid #ccc;
background-color: #fff;
}

table tr:nth-child(2n) {
background-color: #f8f8f8;
}

/* IMAGES
=============================================================================*/

img {
max-width: 100%
}
-->

python Flask教程

例子1:

import flask
from flask import *
app=Flask(__name__) #创建新的开始 @app.route('/') #路由设置
def imdex(): #如果访问了/则调用下面的局部变量
return 'Post qingqiu !' #输出 if __name__ == '__main__':
app.run() #运行开始

访问:127.0.0.1:5000/
结果:

请求方式

例子2:

import flask
from flask import *
app=Flask(__name__)
#flask.request为请求方式
@app.route('/',methods=['GET',"POST"]) #mthods定义了请求的方式
def imdex():
if request.method=='POST': #判断请求
return 'Post qingqiu !'
else:
return 'Get qinqiu !' if __name__ == '__main__':
app.run()

GET请求返回的结果如下:

POST请求如下:

模板渲染

在同一目录下创建一个templates的文件夹,然后里面放入你要调用
的html。使用render_template('要调用的html')
例子3:

import flask
from flask import *
app=Flask(__name__) @app.route('/',methods=['GET',"POST"])
def imdex():
if request.method=='POST':
return 'Post qingqiu !'
else:
return render_template('index.html') #调用html if __name__ == '__main__':
app.run()

index.html代码:

    <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>小灰灰的网络博客</title>
</head>
<body>
<h1>Hello Word</h1>
</body>
</html>

结果:

动态摸版渲染

个人来认为吧,这个应该比较少用到,毕竟是这样子的:/路径/参数
例子:

import flask
from flask import *
app=Flask(__name__) @app.route('/index')
@app.route('/index/<name>') #html里面的参数为name这里也为name动态摸版调用
def index(name): #html里面的参数为name这里也为name
return render_template('index.html',name=name) #调用 if __name__ == '__main__':
app.run()

html代码:

    <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>小灰灰的网络博客</title>
</head>
<body>
<h1>Hello {{name}}!</h1>
</body>
</html>

结果:

接受请求参数

例子:
request.form.请求方式('表单里的数据名称') #用于接受表单传来的数据

import flask
from flask import *
app=Flask(__name__) @app.route('/index/<name>')
def index(name):
return render_template('index.html',name=name) @app.route('/login',methods=['GET','POST']) #可使用的请求有GET和POST
def login():
error=None
if request.method=="GET": #如果请求为GET打开login.html
return render_template('login.html')
else:
username=request.form.get('username') #获取表单里的username数据
password=request.form.get('password') #获取表单里的password数据
if username=='admin' and password=='admin': #判断表单里的username和password数据是否等于admin
return 'login ok' #如果是则返回登录成功 if __name__ == '__main__':
app.run()

html代码:
这里的{{ url_for('login') }} #代表着发送数据

    <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Login</title>
</head>
<body>
<form action="{{url_for('login')}}" method="POST">
<input type="text" name="username">
<input type="password" name="password">
<input type="submit" value="login">
</form>
</body>
</html>

结果如下

输入admin admin
返回如下

python Flask篇(一)的更多相关文章

  1. #3使用html+css+js制作网页 番外篇 使用python flask 框架 (II)

    #3使用html+css+js制作网页 番外篇 使用python flask 框架 II第二部 0. 本系列教程 1. 登录功能准备 a.python中操控mysql b. 安装数据库 c.安装mys ...

  2. #3使用html+css+js制作网页 番外篇 使用python flask 框架 (I)

    #3使用html+css+js制作网页 番外篇 使用python flask 框架(I 第一部) 0. 本系列教程 1. 准备 a.python b. flask c. flask 环境安装 d. f ...

  3. 【Python五篇慢慢弹】快速上手学python

    快速上手学python 作者:白宁超 2016年10月4日19:59:39 摘要:python语言俨然不算新技术,七八年前甚至更早已有很多人研习,只是没有现在流行罢了.之所以当下如此盛行,我想肯定是多 ...

  4. [Python][flask][flask-login]关于flask-login中各种API使用实例

    本篇博文跟上一篇[Python][flask][flask-wtf]关于flask-wtf中API使用实例教程有莫大的关系. 简介:Flask-Login 为 Flask 提供了用户会话管理.它处理了 ...

  5. 细数Python Flask微信公众号开发中遇到的那些坑

    最近两三个月的时间,断断续续边学边做完成了一个微信公众号页面的开发工作.这是一个快递系统,主要功能有用户管理.寄收件地址管理.用户下单,订单管理,订单查询及一些宣传页面等.本文主要细数下开发过程中遇到 ...

  6. 使用Nginx+Uwsgi部署Python Flask项目

    第一次用Flask做Web(也是第一次用Python做Web),在部署的时候遇到了不少问题,现在将过程就下来,供在这方面也有疑惑的人参考.(PS:使用Apache+mod_wsgi部署模式的可以参考另 ...

  7. 前端和后端的数据交互(jquery ajax+python flask+mysql)

    上web课的时候老师布置的一个实验,要求省市连动,基本要求如下: 1.用select选中一个省份. 2.省份数据传送到服务器,服务器从数据库中搜索对应城市信息. 3.将城市信息返回客户,客户用sele ...

  8. 知了课堂 Python Flask零基础 笔记整理

    目录 起步 安装Python2.7: Python虚拟环境介绍与安装: pip安装flask: 认识url: URL详解 web服务器和应用服务器以及web应用框架: Flask 第一个flask程序 ...

  9. Python+Flask+Gunicorn 项目实战(一) 从零开始,写一个Markdown解析器 —— 初体验

    (一)前言 在开始学习之前,你需要确保你对Python, JavaScript, HTML, Markdown语法有非常基础的了解.项目的源码你可以在 https://github.com/zhu-y ...

随机推荐

  1. css输入框的圆角

    转载:http://jingyan.baidu.com/article/73c3ce28f0b38fe50343d926.html 1.原理是四张圆角的图片放在四个角上,就是圆角矩形的四个角,但这种方 ...

  2. JavaScript--变量和运算符

    JavaScript--变量和运算符 一.心得 JavaScript语法:变量声明 var弱类型 var中可以是任何类型在JavaScript里面,单&单|是位运算符.变量没有值使用的话就是u ...

  3. jq对象和DOM对象的互换

    var oJq;  //JQ对象 var oDom; //dom对象 oDom = oJq[index];  // JQ对象转化为oDom对象 oJq  = $(oDom);      //DOM对象 ...

  4. bzoj2705: [SDOI2012]Longge的问题 欧拉定理

    题意:给定一个整数N,你需要求出∑gcd(i, N)(1<=i <=N). 题解:考虑n的所有因子,假设有因子k,那么对答案的贡献gcd(i,n)==k的个数即gcd(i/k,n/k)== ...

  5. hdu1850nim博弈输出问题

    和之前一道题是类似的,输出第一步走的方法,遍历数组找到a[i]^s<a[i]的那个数a[i]-a[i]^s就是要取的数 #include<map> #include<set&g ...

  6. c#在winform中用DataGridView实现分页效果

    public partial class Form11 : Form { public Form11() { InitializeComponent(); } private int Inum = 1 ...

  7. rxjava 调用retrofit执行网络请求的过程

    retrofit流程图 -1.RxJava调用Retrofit,从requestGtPushSaeUserInfo()中获得被观察者observable,然后new一个观察者向它订阅   0.从业务中 ...

  8. Python PIL : IOError: decoder jpeg not available

    The first thing I check when I got this error was to check if libjpeg was installed. Lets try this s ...

  9. spring-security-4 (3)spring security过滤器的创建与注册原理

    spring security是通过一个过滤器链来保护你的web应用安全.在spring security中,该过滤链的名称为springSecurityFilterChain,类型为FilterCh ...

  10. python 生成器 迭代器 yiled

    文章来源:http://python.jobbole.com/81911/ https://www.liaoxuefeng.com/wiki/0014316089557264a6b348958f449 ...