def register():
	if request.method == 'GET':
		try:
			token = get_token()
			return render_template('register.html', token = token)
		except(Exception) as s:
			print s
			return "Hacked by Hcamael", 404
	if request.method == 'POST':
		# 需要接收的参数
		form_list = ('user', 'pass', 'repass', 'code')
		f = request.form
		try:
			e, s = other.check(f, form_list)
		except(Exception) as s:
			print s
			return "leisile!", 404
		if not e:
			return jsonify(error=1, info=s)
		if f['code'] != session['code']:
			return jsonify(error=2, info="验证码输入错误!")
		try:
			if f['token'] != session['token']:
				return ""
		except:
			return ""
		# 检查完成, 插入数据
		try:
			ee, ss = other.adduser(f)
		except(Exception) as s:
			print s
			return "lei!", 404
		if ee:	
			return jsonify(error=0, info=ss)
		else:
			return jsonify(error=1, info=ss)
def login():
	if request.method == 'GET':
		try:
			token = get_token()
			return render_template('login.html', token = token)
		except(Exception) s:
			print s
			return "Hacked by Hcamael", 404
	if request.method == 'POST':
		form_list = ('user', 'pass', 'code')
		f = request.form
		try:
			e, s = other.check(f, form_list)
		except(Exception) as s:
			print s
			return "Hacked by Hcamael", 404
		if not e:
			return jsonify(error=1, info=s)
		if f['code'] != session['code']:
			return jsonify(error=2, info="验证码输入错误!")
		try:
			if f['token'] != session['token']:
				return ""
		except:
			return ""
		try:
			ee, ss = other.ceruser(f)
		except(Exception) as s:
			print s
			return "Hacked by Hcamael", 404
		if ee:
			session['user'] = f['user']
			session['path'] = "./static/upload/"+f['user']
			return jsonify(error=0, info=ss)
		else:
			return jsonify(error=1, info=ss)