-
Notifications
You must be signed in to change notification settings - Fork 0
/
new.py
60 lines (45 loc) · 1.61 KB
/
new.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import os
from google.appengine.ext.webapp import template
from google.appengine.ext.webapp import util
from google.appengine.ext import webapp
from google.appengine.ext import db
from config import *
from gaesessions import get_current_session
from userinfo import UserInfo
import sys
if sys.getdefaultencoding() != 'utf8':
reload(sys)
sys.setdefaultencoding('utf8')
_DEBUG=True
class NewHandler(webapp.RequestHandler):
def post(self):
nickname = self.request.get('nickname')
password = self.request.get('password')
confirmpassword = self.request.get('confirmpassword')
if password != confirmpassword:
self.response.out.write("Password not match")
return
userinfos = UserInfo.gql("WHERE nickname=:1",nickname)
found = 0
for userinfo in userinfos:
userinfo = UserInfo()
userinfo.nickname = nickname
userinfo.password = password
userinfo.put()
found = 1
break
if found == 0:
userinfo = UserInfo()
userinfo.nickname = nickname
userinfo.password = password
userinfo.put()
self.response.out.write("updated")
self.redirect("login.html")
application = webapp.WSGIApplication([
('/new', NewHandler)
],
debug=True)
def main():
util.run_wsgi_app(application)
if __name__ == '__main__':
main()