【Python web 开发】 bottle 简单教程 (三)
来源:互联网 发布:汉服出租淘宝 编辑:程序博客网 时间:2024/05/29 03:44
Login in 登录
学什么编程语言的第一个都是hello world,做web的第一个应该就是login in 登录了吧
一:pro截图
二:index.py
from bottle import route, run, template, request#登录@route("/login",method="post")def login(): username = request.forms.get("username"); password = request.forms.get("password"); print(username,password) if username =='admin' and password =='admin': return username+'登录成功'; else : return username+'登录失败';#用户登录页面的@route("/index")def index(): return template("index")#@route('/hello/:name')#def index(name='World'):# return '<b>Hello %s!</b>' % name#默认端口 run(host='localhost', port=8080)run()
三:index.tpl
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Insert title here</title></head><body><form action="/login" method="post">用户名:<input type="text" name="username" />密码:<input type="password" name="password" /></br><input type="submit" value='login'/></form></body></html>
四:效果
失败:
成功:
- 【Python web 开发】 bottle 简单教程 (三)
- 【Python web 开发】 bottle 简单教程 (一)
- 【Python web 开发】 bottle 简单教程 (二)
- 【Python web 开发】 bottle 简单教程 (四)
- [深度分析] Python Web 开发框架 Bottle
- Python web frame:Bottle
- 【Python】Python用Bottle轻量级框架进行Web开发
- Python使用Bottle来提供一个简单的web服务
- python bottle 搭建最简单的 web服务器
- [深度分析] Python Web 开发框架 Bottle(作者 @Sunng)
- Python用Bottle轻量级框架进行Web开发
- 微型 Python Web 框架: Bottle
- 微型 Python Web 框架: Bottle
- Python --- Bottle: 轻量级Web Server
- 微型 Python Web 框架: Bottle
- 【Python Web Framework】Bottle框架
- 微型 Python Web 框架: Bottle
- 【Python】Bottle框架下Python Web开发的跨域访问
- Three20
- OpenGL中的变换
- #define总结 (网上资料汇集)
- mysql 备份数据库
- Java实现ftp上传文件、文件夹
- 【Python web 开发】 bottle 简单教程 (三)
- HDU2583 f(n) 规律题
- 编写跨浏览器兼容的 CSS 代码
- 关于vc++2005/vc++.net调试com组件时断点设置无效的问题
- C/C++头文件一览
- linux下makefile
- 关于linux基础命令的学习
- typedef 用法大全
- 将汉字转换成汉语拼音方法,Pinyin4j入门教程