python模拟开发一个网站
来源:互联网 发布:诊疗指南软件下载 编辑:程序博客网 时间:2024/05/18 16:58
# _*_ coding:utf-8 _*_import weburls = ( '/','Index', '/reg','Reg', '/user','User', '/login','Login',)web.config.debug=False #设置成非调测模式app = web.application(urls,globals())session = web.session.Session(app,web.session.DiskStore('G:\\sessions')) #创建一个session对象render = web.template.render('templates') #去搜索文件下的资源db = web.database(dbn = 'mysql',host='127.0.0.1',port='3306',user='root',pw='root',db='test',charset='utf8')class Index: def GET(self):#方法名字根据用户请求方式定义 return render.index() def POST(self): i = web.input() username = i.username password = i.password data=db.query("select * from user where username ='%s' and password = '%s' " %(username,password)) if not data:return '账号或者密码错误' web.setcookie('user','%s' %username,600000) web.setcookie('pwd','%s' %password,600000) session.logged_id = True raise web.sessother('/user')class Reg: def GET(self): return render.reg() def POST(self): i = web.input() #用户发送的请求 username = i.username password = i.password password2 = i.password2 if password != password2: return '两次密码不一致' else: #插入用户信息前做用户是否已经存在注册过,密码进行佳美 db.query("insert into user(userid,username,password,text) values(null,'%s','%s',%s)" %(username,password,0)) session.logged_in = True #当前用户的session生效后就有权限登录 raise web.seeother('/user')#cookies,sessionclass User: def GET(self): if session.get('logged_in'): return render.user() else: return '还没有登录或过期' def POST(self): url = web.input().link file,title=get_file.getfile(url) if not session.get('logged_in'):return '还没有权限' web.header('Content-Disposition:attachment;filename =%s.doc' %title) web.header('Content-Type:application/msword;') return fileif __name__ == '__main__': app.run()
0 0
- python模拟开发一个网站
- python模拟登陆网站
- python模拟网站登陆
- python模拟网站登录
- python模拟一个浏览器
- Python模拟浏览器登陆网站
- 模拟网站登录实现----Python
- Python模拟用户登陆网站
- Python模拟浏览器登陆网站
- python requests 模拟网站登录
- python模拟浏览器访问网站
- PHP开发一个网站
- 如何开发一个网站
- 前端一个开发网站
- 网站模拟登陆备忘(php + python)
- python模拟登陆网站示例类
- python模拟登陆网站抓取数据
- python模拟登陆后用户访问网站
- 【LeetCode】 240. Search a 2D Matrix II
- 79. Word Search
- 【LeetCode】 334. Increasing Triplet Subsequence
- 1.15三道水题题解
- 周有光2017年1月14日去世,享年112岁
- python模拟开发一个网站
- The operation couldn’t be completed. Unable to log in with account ''. An unexpected failure occurre
- 【LeetCode】 077. Combinations
- 实现分享到QQ空间 新浪微博等等
- Ashampoo.Snap.9.v9.0.5-AMPED
- Ashampoo.ZIP.Pro.2.v2.0.0-AMPED
- 感谢CSDN网管员,多数科普博文已经恢复搜索访问
- leetcode 485
- BZOJ3107: [cqoi2013]二进制a+b