#!/usr/bin/env python3.5
from tools.application import Application
from tools.template import Template
from tools.httptools import Route
from models import *
import hashlib
@Route.get('/')
def index():
	user=yield from  User().findone()
	print(user.email)
	return Template('index.html').render()
@Route.get('/user/{id}/comment/{comment}')
def user(id,comment):
	u=User()
	user=yield from u.findone()
	return Template('index.html').render(user=user)
@Route.get('/user/register')
def get_register():
	return Template("register.html").render()
@Route.post('/user/register')
def register(username,email,password):
	u=User()
	u.user_name=username
	md5=hashlib.md5()
	md5.update(password.encode('utf-8'))
	u.password=md5.hexdigest()
	u.email=email
	yield from u.save()
	return '<h1>OK</h1>'
if __name__=="__main__":
	app=Application()
	app.run()


@@ -166,16 +166,28 @@
 hashlib%0A
+import uuid%0A
 @Route.g
@@ -204,16 +204,19 @@
 f index(
+app
 ):%0A%09user
@@ -269,45 +269,396 @@
 l)%0A%09
-return Template('index.html').render(
+app.set_cookie('sl',uuid.uuid1())%0A%09app.set_cookie('date',uuid.uuid4())%0A%09#app.clear_cookie('sl')%0A%09return Template('index.html').render(user=user)%0A@Route.get('/clc_cookie')%0Adef clc_cookie(app):%0A%09app.clear_all_cookies()%0A%09return 'ok'%0A@Route.get('/get_cookie')%0Adef get_cookie(app):%0A%09sl=app.get_cookie('sl')%0A%09date=app.get_cookie('date')%0A%09print(app.get_all_cookies())%0A%09return '%25s%5Cr%5Cn%25s'%25(sl,date
 )%0A@R
@@ -707,16 +707,20 @@
 ef user(
+app,
 id,comme
@@ -858,16 +858,19 @@
 egister(
+app
 ):%0A%09retu
@@ -954,31 +954,11 @@
 ter(
-username,email,password
+app
 ):%0A%09
@@ -983,16 +983,34 @@
 ame=
+app.get_argument('
 username
 %0A%09md
@@ -1005,16 +1005,18 @@
 username
+')
 %0A%09md5=ha
@@ -1027,16 +1027,55 @@
 b.md5()%0A
+%09password=app.get_argument('password')%0A
 %09md5.upd
@@ -1141,21 +1141,41 @@
 u.email=
+app.get_argument('
 email
+')
 %0A%09yield 

add cookie testing code