mirror of https://github.com/interlegis/sapl.git
Gustavo274
3 years ago
5 changed files with 17 additions and 52 deletions
@ -1,27 +1,14 @@ |
|||
import json |
|||
import requests |
|||
import urllib |
|||
|
|||
from celery import shared_task |
|||
from urllib import request |
|||
|
|||
from channels.layers import get_channel_layer |
|||
from asgiref.sync import async_to_sync |
|||
|
|||
from sapl.painel import views |
|||
|
|||
channel_layer = get_channel_layer() |
|||
|
|||
@shared_task |
|||
def get_cronometro(): |
|||
url_dados = 'http://localhost:8000/painel/786/dados' |
|||
|
|||
|
|||
login_data = {'username': 'sapl', 'password': 'sapl'} |
|||
with requests.Session() as session: |
|||
session.get('http://localhost:8000/login/') |
|||
csrftoken = session.cookies['csrftoken'] |
|||
login_data['csrfmiddlewaretoken'] = csrftoken |
|||
post = session.post('http://localhost:8000/login/', data=login_data) |
|||
if post.ok: print('conexao realizada com sucesso') |
|||
r = session.get('http://localhost:8000/painel/786/dados') |
|||
json_data = r.json() |
|||
|
|||
def get_dados_painel_celery(): |
|||
json_data = views.get_dados_painel(786) |
|||
async_to_sync(channel_layer.group_send)('painel', {'type':'send_data', 'message': json_data}) |
|||
|
Loading…
Reference in new issue