exodus专辑封面:[Python]尝试用webpy写了个很山寨的登录页面
来源:百度文库 编辑:中财网 时间:2024/05/03 04:23:09
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- #author:zeal
- #只是判断了下有没有cookie,没有就算没登录.
- import web
- # For debugging use only
- web.internalerror = web.debugerror
- render = web.template.render('template/')
- urls = (
- '/', 'index',
- '/logout', 'logout',
- )
- class index:
- def GET(self):
- cookie = web.cookies()
- islogin = False
- if cookie :
- islogin =True
- print 'islogin=',islogin
- return render.index(islogin)
- def POST(self):
- cache = False
- cookie = web.cookies()
- #user accout and password
- userdb = [('test','test'),
- ('a','a'),
- ]
- i = web.input(name = "guest",password ="guest")
- print i
- print 'webdata.usn=',str(i['usn'])
- print 'webdata.pwd=',str(i['pwd'])
- usn = str(i['usn'])
- pwd = str(i['pwd'])
- result = (usn,pwd) in userdb
- if result :
- web.setcookie('name', usn,3600)
- web.setcookie('password', pwd,3600)
- web.seeother('/')
- else:
- login = 'wrong user name or password'
- raise web.seeother('/')
- class logout:
- def GET(self):
- web.setcookie('name', '', 'Mon, 01-Jan-2001 00:00:00 GMT')
- web.setcookie('password', '', 'Mon, 01-Jan-2001 00:00:00 GMT')
- raise web.seeother('/')
- if __name__ == "__main__":
- app = web.application(urls, globals())
- app.run()
Python怎么用
尝试仿写
尝试集是谁写的
尝试写一句话;外部世界反映了心理活动,这是对心理活动错误的认识
python比perl更好用吗?
现在还有没有人用python编程?
现在还有没有人用python编程?
python,perl,php都是干什么用的
Python code, 用 “builder” pattern refactoring 谢谢!
我已经干个很长时间出纳了,但我想尝试一下会计的工作,但我会计工作又不是很精通,我该怎么办
GoogleDesktopIndex.exe是个什么文件?它尝试成为服务器程序,我是该禁止还是该允许?谢谢了!
现在国内有多少人用python编程?
Python、Java做网站和编程用哪个好?
有人知道python是干什么用的吗?
{急}请教:用python语言解析xml文件
python学习
关于python
Python咯!~~
什么是Python?
什么是Python?
什么是Python
python难吗?
Python读音
我尝试发了一个帖子