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. jq 抖动效果

    1 .html <div style="margin:50px auto;width:900px;overflow:visible;"> <div id=&quo ...

  2. ActiveMQ---知识点整理

    本文来自于csdn,文章通过介绍ActiveMQ的安装,使用,搭建等等,简单整理了ActiveMQ. 本文转自:http://www.uml.org.cn/zjjs/201802111.asp 一.背 ...

  3. PHP-----------HTTP请求的第三方接口

    开发中常常遇到接口请求这个功能,后台也不例外,因为遇到了,所以写一篇. 前段时间做商城后台时,需要用到第三方物流接口查询物流信息. post: /**** * @param $url * @param ...

  4. HDU - 4812 D Tree 点分治

    http://acm.hdu.edu.cn/showproblem.php?pid=4812 题意:有一棵树,每个点有一个权值要求找最小的一对点,路径上的乘积mod1e6+3为k 题解:点分治,挨个把 ...

  5. hdu3032sg打表找规律

    先打个表冷静一下 #include<map> #include<set> #include<cmath> #include<queue> #includ ...

  6. HDU 4522 (恶心建图)

    湫湫系列故事——过年回家 Time Limit: 500/200 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total ...

  7. 009PHP文件处理——文件处理 file_get_contents file_put_contents fgetc fgets fgetss

    <?php /** * 文件处理 file_get_contents file_put_contents fgetc fgets fgetss */ //fgetc() 传入文件操作句柄.每次获 ...

  8. Java基础——概述

    body, table{font-family: 微软雅黑; font-size: 10pt} table{border-collapse: collapse; border: solid gray; ...

  9. 安装wamp后,127.0.0.1可以访问,localhost不能访问

    今天安装wamp后,127.0.0.1可以访问,localhost不能访问,出现 “error You don't have permission to access”的错误, 网上查了下,很多方法都 ...

  10. 1元抢卡巴KAV_不限量疯抢即日起至2013.10.31截止

    活动地址:http://img.kaba365.com/mail_files/kaba1yuan.html