Skip to content

Commit

Permalink
add remote led but not add any device control yeah.
Browse files Browse the repository at this point in the history
  • Loading branch information
junstrix committed Apr 6, 2013
1 parent 13cff19 commit 0a12feb
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 5 deletions.
4 changes: 3 additions & 1 deletion control/templates/con/base.html
Expand Up @@ -2,7 +2,9 @@
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />

<script type="text/javascript" src="http://lib.sinaapp.com/js/jquery/1.8.3/jquery.min.js"></script>

</script>
<title>{% block title %}

{% endblock %}</title>
Expand Down
5 changes: 4 additions & 1 deletion control/templates/con/control.html
Expand Up @@ -3,5 +3,8 @@
{{ led_center }}
{% endblock %}
{% block content %}

<form action="/control/control/" method="post" accept-charset="utf-8">
<input type="image" height="100" src="{{ light_bol }}" name="l_status" id="light" value="{{ light_status }}" />
<!--<input type="submit" name="" id="" value="开灯" />-->
</form>
{% endblock %}
1 change: 1 addition & 0 deletions control/urls.py
Expand Up @@ -16,6 +16,7 @@
(r'^control/','control.views.control'),
(r'^logout/','control.views.logout'),
(r'^led/','control.views.led'),
(r'^test/','control.views.test'),
(r'^search_form/','control.views.search_form'),
(r'^search/','control.views.search'),
(r'^static/(?P<path>.*)$', 'django.views.static.serve'),
Expand Down
17 changes: 14 additions & 3 deletions control/views.py
Expand Up @@ -52,8 +52,19 @@ def login(request):

def control(request):
"""get a post control gpio"""
if not request.user.is_authenticated():
return HttpResponse("你无权访问...")
led_center="raspberry pi control"
current_time = datetime.today()
return render_to_response('con/control.html',{'led_center':led_center,'current_time':current_time})
light_bol = "/static/eg_bulboff.gif"
light_status = "on"
if not request.user.is_authenticated():
return HttpResponse("你无权访问...")
if request.POST.get('l_status','') == 'on':
light_bol = "/static/eg_bulbon.gif"
light_status = "off"
return render_to_response('con/control.html',{'led_center':led_center,'current_time':current_time,'light_bol':light_bol,'light_status':light_status})
def test(request):
"""test"""
if request.POST.get('l_status','') == 'on':
return HttpResponse("success!")
else:
return HttpResponse("failed!")
Binary file modified pi_dev/settings.pyc
Binary file not shown.
Binary file added pi_dev/static/eg_bulboff.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pi_dev/static/eg_bulbon.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0a12feb

Please sign in to comment.