ospaz-site/index/views.py

32 lines
999 B
Python

import os
from django.http import HttpResponse
from django.shortcuts import render
# from django.db.models import Manager
# только для тестирования!
import requests
TEST_BASE_FETCH = "https://test.wawaa.ru/dev-fetch.php"
def view_index(request):
return render(request, 'index.html')
def view_stats(request):
# только для тестирования!
res = requests.get(TEST_BASE_FETCH + "?stats", headers={'Authorization': os.getenv("TEST_AUTH")})
response = HttpResponse(res.content)
response.headers["Content-type"] = response.headers["Content-type"]
return response
def view_tank_chart(request):
# только для тестирования!
days = request.GET.get('days', '7')
res = requests.get(TEST_BASE_FETCH + "?tank_chart=" + days, headers={'Authorization': os.getenv("TEST_AUTH")})
response = HttpResponse(res.content)
response.headers["Content-type"] = response.headers["Content-type"]
return response