v0.0.00.5
This commit is contained in:
parent
62464ea1a7
commit
7146efe8c6
@ -1,23 +1,23 @@
|
||||
# from django.conf import settings
|
||||
# from django.shortcuts import redirect
|
||||
# import re
|
||||
from django.conf import settings
|
||||
from django.shortcuts import redirect
|
||||
import re
|
||||
|
||||
# EXEMPT_URLS = [
|
||||
# re.compile(settings.LOGIN_URL.lstrip('/')), # eg. 'streaming/login/'
|
||||
# re.compile(r'^admin/login/$'), # админ-логин
|
||||
# re.compile(r'^streaming/login/$'), # <-- добавь это!
|
||||
# re.compile(r'^streaming/$'),
|
||||
# re.compile(r'^static/'),
|
||||
# re.compile(r'^media/'),
|
||||
# ]
|
||||
EXEMPT_URLS = [
|
||||
re.compile(settings.LOGIN_URL.lstrip('/')), # eg. 'streaming/login/'
|
||||
re.compile(r'^admin/login/$'), # админ-логин
|
||||
re.compile(r'^streaming/login/$'),
|
||||
re.compile(r'^streaming/$'),
|
||||
re.compile(r'^static/'),
|
||||
re.compile(r'^media/'),
|
||||
]
|
||||
|
||||
# class LoginRequiredMiddleware:
|
||||
# def __init__(self, get_response):
|
||||
# self.get_response = get_response
|
||||
class LoginRequiredMiddleware:
|
||||
def __init__(self, get_response):
|
||||
self.get_response = get_response
|
||||
|
||||
# def __call__(self, request):
|
||||
# path = request.path_info.lstrip('/')
|
||||
# if not request.user.is_authenticated:
|
||||
# if not any(pattern.match(path) for pattern in EXEMPT_URLS):
|
||||
# return redirect(settings.LOGIN_URL)
|
||||
# return self.get_response(request)
|
||||
def __call__(self, request):
|
||||
path = request.path_info.lstrip('/')
|
||||
if not request.user.is_authenticated:
|
||||
if not any(pattern.match(path) for pattern in EXEMPT_URLS):
|
||||
return redirect(settings.LOGIN_URL)
|
||||
return self.get_response(request)
|
||||
@ -87,11 +87,11 @@ TEMPLATES = [
|
||||
CSRF_COOKIE_SECURE = False
|
||||
SESSION_COOKIE_SECURE = False
|
||||
|
||||
CSRF_TRUSTED_ORIGINS = ['http://192.168.0.169']
|
||||
# CSRF_TRUSTED_ORIGINS = ['http://192.168.0.169']
|
||||
|
||||
WSGI_APPLICATION = 'app.wsgi.application'
|
||||
|
||||
LOGIN_REDIRECT_URL = '/streaming/'
|
||||
|
||||
|
||||
# Database
|
||||
# https://docs.djangoproject.com/en/5.2/ref/settings/#databases
|
||||
|
||||
BIN
web/db.sqlite3
BIN
web/db.sqlite3
Binary file not shown.
@ -3,4 +3,5 @@ from . import consumer
|
||||
|
||||
websocket_urlpatterns = [
|
||||
re_path(r'ws/stream/$', consumer.VideoConsumer.as_asgi()),
|
||||
re_path(r'ws/stream$', consumer.VideoConsumer.as_asgi())
|
||||
]
|
||||
@ -15,8 +15,8 @@ def login_view(request):
|
||||
login(request, user)
|
||||
return redirect('stream')
|
||||
else:
|
||||
return render(request, 'templates/login.html', {'error': 'Неверный логин или пароль'})
|
||||
return render(request, 'templates/login.html')
|
||||
return render(request, 'login.html', {'error': 'Неверный логин или пароль'})
|
||||
return render(request, 'login.html')
|
||||
|
||||
def logout_view(request):
|
||||
logout(request)
|
||||
@ -25,7 +25,7 @@ def logout_view(request):
|
||||
@login_required
|
||||
def stream_view(request):
|
||||
history = DetectionHistory.objects.all()[:20]
|
||||
return render(request, 'templates/streaming/stream.html',{
|
||||
return render(request, 'streaming/stream.html',{
|
||||
"websocket_url": settings.WEBSOCKET_URL,
|
||||
"history": history
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user