Download pool/shard004/Python/0035925_ajax.py from Variable-role/sajaniemi_variable_dataset_large: direct link, hf CLI and curl.
- Browser
- Download file 1.51 kB
-
https://huggingface.co/datasets/Variable-role/sajaniemi_variable_dataset_large/resolve/main/pool/shard004/Python/0035925_ajax.py
- Command line
-
hf download hf://datasets/Variable-role/sajaniemi_variable_dataset_large/pool/shard004/Python/0035925_ajax.py
-
curl -L -o 0035925_ajax.py https://huggingface.co/datasets/Variable-role/sajaniemi_variable_dataset_large/resolve/main/pool/shard004/Python/0035925_ajax.py
1.51 kB
| from django.http import HttpResponse | |
| from django.http import HttpRequest | |
| from django.core import serializers | |
| from controles.models import Controle,Bloco,Sala | |
| from django.shortcuts import render_to_response | |
| from controles.protocolo import Protocolo,Weather | |
| from django.views.decorators.csrf import csrf_exempt, csrf_protect | |
| def sendIR(request): | |
| if request.method == 'POST': | |
| data = request.POST['comando'] | |
| node= request.POST['node'] | |
| pr = Protocolo() | |
| message = "OK" | |
| if not pr.sendIR(node,data): | |
| message = "ERROR" | |
| return HttpResponse(message,content_type = 'application/javascript; charset=utf8' ) | |
| else : | |
| return render_to_response('controles/404.html') | |
| def sendRele(request): | |
| if request.method == 'POST': | |
| data = request.POST['comando'] | |
| node= request.POST['node'] | |
| pr = Protocolo() | |
| message = "OK" | |
| if not pr.sendRele(node,data): | |
| message = "ERROR" | |
| return HttpResponse(message,content_type = 'application/javascript; charset=utf8' ) | |
| else : | |
| return render_to_response('controles/404.html') | |
| def getWeather(request): | |
| if request.method == 'POST': | |
| node= request.POST['node'] | |
| pr = Protocolo() | |
| weather = pr.sendWeather(node) | |
| try: | |
| return HttpResponse('["'+weather.umidade+'","'+weather.temperatura+'"]',content_type = 'application/json' ) | |
| except: | |
| return HttpResponse('error',content_type = 'application/json' ) | |
| else : | |
| return render_to_response('controles/404.html') | |