mirror of https://github.com/interlegis/sapl.git
Gustavo274
3 years ago
4 changed files with 36 additions and 0 deletions
Binary file not shown.
Binary file not shown.
@ -0,0 +1,17 @@ |
|||
import os |
|||
from celery import Celery |
|||
|
|||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'sapl.settings') |
|||
|
|||
app = Celery('sapl') |
|||
|
|||
app.config_from_object('django.conf:settings', namespace='CELERY') |
|||
|
|||
app.conf.beat_schedule = { |
|||
'get_cronometro_inst': { |
|||
'task': 'sapl.painel.tasks.get_cronometro', |
|||
'schedule': 10.0 |
|||
} |
|||
} |
|||
|
|||
app.autodiscover_tasks() |
@ -0,0 +1,19 @@ |
|||
import json |
|||
import requests |
|||
import urllib |
|||
|
|||
from celery import shared_task |
|||
|
|||
|
|||
@shared_task |
|||
def get_cronometro(): |
|||
url_dados = 'http://localhost:8000/painel/1272/dados' |
|||
# print(requests.get(url_dados).status_code) |
|||
#response = requests.get(url_dados) |
|||
response = urllib.request.urlopen(url_dados) |
|||
dados = json.loads(response.read()) |
|||
#cronometro = response['sessao_plenaria']['cronometro_discurso'] |
|||
print(dados) |
|||
print(response) |
|||
print(response.encoding) |
|||
return response |
Loading…
Reference in new issue