基于Dragonboard 410c服务器系列之二局域网用户管理系统
转index
response = HttpResponseRedirect('/online/index/')
#将username写入浏览器cookie,失效时间为3600
response.set_cookie('username',username,3600)
return response
else:
#比较失败,跳转loginfaild
return render_to_response('loginfaild.html',{'uf':uf},context_instance=RequestContext(req))
else:
uf = UserForm()
#return render_to_response('registfaild.html',{'uf':uf},context_instance=RequestContext(req))
return render_to_response('registsuccee.html',{'uf':uf},context_instance=RequestContext(req))
#
#def registfaild(req):
# response = regist(req)
# return response
#
#def registfaild1(req):
# response = regist(req)
# return response
#登陆成功
def index(req):
username = req.COOKIES.get('username','')
user_list=getAllUser(req)
if req.method == 'POST':
key_user=req.POST.get('username')
key_input=req.POST.get('text')
print(key_user)
print(key_input)
if key_input=='text':
print('please input text')
response = HttpResponseRedirect('/online/text/')
#将username写入浏览器cookie,失效时间为3600
response.set_cookie('username',username,3600)
return response
elif key_input=='video':
print('please input video')
response = HttpResponseRedirect('/online/video/')
#将username写入浏览器cookie,失效时间为3600
response.set_cookie('username',username,3600)
return response
else:
return render_to_response('loginsuccee.html' ,{'user_list':user_list,'username':username},)
# user_sum=user_list.count()
# if req.method == 'POST':
# if req.POST['username']=="ad3600":
# if req.post.get('text')=="video":
return render_to_response('loginsuccee.html' ,{'user_list':user_list,'username':username},)
#退出
def logout(req):
response = login(req)
response.delete_cookie('username')
return response
#response = HttpResponse('logout !!')
#清理cookie里保存username
# response.delete_cookie('username')
# return response
def getAllUser(req):
user_list=User.objects.all().values('username')
user_sum=User.objects.all().values('username').count()
print(user_list)
print(user_sum)
return user_list
def text(req):#输入文本处理
username = req.COOKIES.get('username','')
if req.method == 'POST':
text = req.POST['text_input']
print(req.user.is_anonymous())
req.user.text=text
req.user.username=username
print(username)
print(req.user.get_full_name())
print(req.user.text)
req.user.save()
# print(dir(MyUser))
return render_to_response('text.html',)
def video(req):#输入视频处理
return req
def delete():
User.objects.filter().delete()
2.2.online/urls
from django.conf.urls import patterns, url
from online import views
import register.setTIngs
urlpatterns = patterns('',
url(r'^$', views.login, name='login'),
url(r'^login/$',views.login,name = 'login'),
url(r'^loginfail/$',views.login,name = 'loginfail'),
url
DragonBoard 410c Web服务器 局域网 相关文章: