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. PistgreSQL9.6手册(基础摘录)

    学习目的:基础使用. 能够开发RoR就行. git: https://github.com/postgres-cn/pgdoc-cn 1.2. 架构基础 PostgreSQL使用一种客户端/服务器的模 ...

  2. SpringMVC中的参数绑定总结

    众所周知,springmvc是用来处理页面的一些请求,然后将数据再通过视图返回给用户的,前面的几篇博文中使用的都是静态数据,为了能快速入门springmvc,在这一篇博文中,我将总结一下springm ...

  3. js取整,保留小数位数、四舍五入、科学记数法及去掉数字末尾多余的0

    1.向下取整 var num1 = 12.10345; var num2 =12.9801; var newnum1=Math.floor(num1)     //结果 12 var newnum2= ...

  4. 044——VUE中组件之使用内容分发slot构建bootstrap面板panel

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  5. 99%的人都理解错了HTTP中GET与POST的区别(转自知乎)

    作者:Larry链接:https://zhuanlan.zhihu.com/p/22536382来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明出处. GET和POST是HTT ...

  6. 如何创建管理员权限的CMD命令提示符窗口

    最近在使用netstat -anob命令时提示 请求的操作需要提升. 总结了几种创建管理员权限的CMD命令行的方法. 创建临时管理员权限的CMD Win8系统: 按下windows徽标,直接输入cmd ...

  7. IOS中UITableViewCell使用详解

    IOS中UITableViewCell使用详解 - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(N ...

  8. python中django框架的csrf验证

    在form表单以post的方式提交时,django默认会带一个验证的机制csrf验证 <form action="/day02/login/" method="po ...

  9. ballerina 学习二十二 弹性服务

    主要包含断路器模式,负载均衡模式,故障转移,重试 Circuit Breaker 参考代码 import ballerina/http; import ballerina/log; import ba ...

  10. Java多线程编程核心技术,第四章

    1,ReentrantLock 2,object的wait(),wait(x),notify(),notifyAll(),分别等于Condition的await(),await(x,y),signal ...