任务需求:一个登录,注册页面

任务环境:pycharm 2018 专业版,python3.7,win 10专业版

-----------------------------------------------------------------------------------------------------------------------------------------------------------------

前端页面 ,比较简单,自己随便做的,能传进参数就好,还没有和前端的人正式交接

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<form action="{{ url_for('login')}}" method="post">
用户:<input type="text" name = 'uname'>
密码: <input type="password" name = "upwd">
<input type="submit" value="提交">
</form>
</body>
</html>

--------------------------------------------------------

后端的py,先写一个注册页 ,有空再把数据库整理整理给上线了

#先导入数据库
from flask import Flask ,request ,render_template

app = Flask(__name__)

#对flask进行一个初始化

@app.route('/')

def index():

return "这是一个首页"

@app.route('/login/', methods=['POST' ,'GET'])

def login():
if request.method == "POST":
user = request.form.get('uname')
pwd = request.form.get('upwd')
return ("user = %s , pwd = %s " % (user , pwd))
if request.method == 'get':
return "这个请求方式不是post"

@app.route('/login1/')
def login_html():
return render_template('login.html')

if __name__ == '__main__':
app.run(debug = True)

这里选中的是post参数,在Python中接受参数会是一个 request.form.get("前端name属性的值")

get 方式提交的化,在python中接受参数会是一个request.args.get("前端name属性的值")

很多人为什么写不对post提交方式,因为python在对request.method 验证的比较好,要是小写的post就会使不正确的 。必须是大写的

if request.method == "POST":

最新文章

  1. NOIP2016之反面教材提供
  2. Ext Js【Hello World】 ——4.1 beta 1
  3. postgresql数据类型转换
  4. Java-如何挖取某个网站中的ajax请求信息
  5. c# TCPclient
  6. shell script创建库
  7. PD生成oracle表名带引号解决方案
  8. C#读取数据库返回泛型集合(DataSetToList)
  9. thinkphp5踩坑之部署到服务器模板不存在
  10. poj2635 同余定理 + 素数筛法
  11. &quot;贪吃蛇&quot;-css3效果
  12. sshpass 使用方法
  13. 为什么不要使用 select * from xxx (oracle 亲测)
  14. cnn 滤波
  15. linux动态查看某组进程状态的办法
  16. &quot;strcmp()&quot; Anyone? UVA - 11732(trie出现的次数)
  17. 无线路由MAC地址过滤安全可靠性讨论
  18. python常用命令—windows终端查看安装包信息
  19. C++中的config设计
  20. MATLAB之画确定区域内不重合的随机圆

热门文章

  1. 万字长文,详解推荐系统领域经典模型FM因子分解机
  2. 如何使用 gitlab 或 github 执行npm run build
  3. python类继承中构造子的调用
  4. &lt;摘自&gt;飞:jxl简析2 [ http://www.emlog.net/fei ]
  5. [MIT6.006] 5. Binary Search Trees, BST Sort 二分搜索树,BST排序
  6. Socket 连接错误及原因
  7. leetcode bitmap系列问题整理
  8. MTK官方SDK包编译openwrt
  9. linux文件的3个时间和7种文件类型
  10. Redis在springboot项目的使用