v0.0.4
This commit is contained in:
parent
cc8abbe006
commit
75b55eb9a3
@ -1,7 +1,14 @@
|
||||
SECRET_KEY - секретный ключ django
|
||||
RTSP_URL - путь до камеры. Пример: rtsp://admin:admin@192.168.1.108:554/cam/realmonitor?channel=1&subtype=0
|
||||
MODEL_PATH - относительный путь до модели нейросети. Находятся по пути web/models
|
||||
|
||||
развертывание:
|
||||
1) git clone https://git.cybercode.pro/roman/liquid.git
|
||||
2) задаем переменные .env
|
||||
3) docker-compose up --build
|
||||
3) проверка драйвера nvidia, если нужно использовать на gpu, командой - nvidia-smi
|
||||
4) в зависимости от версии выбрать нужный docker-compose
|
||||
5) для версии cuda 12.8 - docker-compose -f docker-compose-gpu-cuda128-dev.yaml up --build -d
|
||||
|
||||
|
||||
login - user
|
||||
password - 4dpnJdw8CSqUx7Y
|
||||
21
web/app/middleware.py
Normal file
21
web/app/middleware.py
Normal file
@ -0,0 +1,21 @@
|
||||
from django.conf import settings
|
||||
from django.shortcuts import redirect
|
||||
import re
|
||||
|
||||
EXEMPT_URLS = [
|
||||
re.compile(settings.LOGIN_URL.lstrip('/')), # eg. '^login/$'
|
||||
re.compile(r'^admin/login/$'), # админ-логин
|
||||
re.compile(r'^static/'), # статика
|
||||
re.compile(r'^media/'), # медиаконтент
|
||||
]
|
||||
|
||||
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)
|
||||
@ -57,8 +57,12 @@ MIDDLEWARE = [
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
'whitenoise.middleware.WhiteNoiseMiddleware',
|
||||
'app.middleware.LoginRequiredMiddleware',
|
||||
]
|
||||
|
||||
LOGIN_URL = '/login/'
|
||||
LOGIN_REDIRECT_URL = '/'
|
||||
|
||||
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
|
||||
|
||||
|
||||
@ -67,7 +71,7 @@ ROOT_URLCONF = 'app.urls'
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
'DIRS': [],
|
||||
'DIRS': [os.path.join(BASE_DIR, 'templates')],
|
||||
'APP_DIRS': True,
|
||||
'OPTIONS': {
|
||||
'context_processors': [
|
||||
@ -83,6 +87,7 @@ TEMPLATES = [
|
||||
|
||||
WSGI_APPLICATION = 'app.wsgi.application'
|
||||
|
||||
LOGIN_REDIRECT_URL = '/streaming/'
|
||||
|
||||
# Database
|
||||
# https://docs.djangoproject.com/en/5.2/ref/settings/#databases
|
||||
|
||||
@ -16,8 +16,13 @@ Including another URLconf
|
||||
"""
|
||||
from django.contrib import admin
|
||||
from django.urls import path, include
|
||||
from django.contrib.auth import views as auth_views
|
||||
|
||||
urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
# path('accounts/', include('django.contrib.auth.urls')),
|
||||
path('login/', auth_views.LoginView.as_view(template_name='registration/login.html'), name='login'),
|
||||
path('logout/', auth_views.LogoutView.as_view(next_page='/login/'), name='logout'),
|
||||
path('admin/', admin.site.urls),
|
||||
path('streaming/', include("streaming.urls"))
|
||||
]
|
||||
|
||||
BIN
web/db.sqlite3
BIN
web/db.sqlite3
Binary file not shown.
30
web/templates/registration/login.html
Normal file
30
web/templates/registration/login.html
Normal file
@ -0,0 +1,30 @@
|
||||
{% load static %}
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Вход</title>
|
||||
<link rel="stylesheet" href="{% static 'css/style.css' %}">
|
||||
</head>
|
||||
<body>
|
||||
<h2>Авторизация</h2>
|
||||
{% if form.errors %}
|
||||
<p style="color: red;">Логин или пароль неверны</p>
|
||||
{% endif %}
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
<table>
|
||||
<tr>
|
||||
<td>{{ form.username.label_tag }}</td>
|
||||
<td>{{ form.username }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{{ form.password.label_tag }}</td>
|
||||
<td>{{ form.password }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
<button type="submit">Войти</button>
|
||||
</form>
|
||||
{# <p><a href="{% url 'password_reset' %}">Забыли пароль?</a></p> #}
|
||||
</body>
|
||||
</html>
|
||||
0
web/templates/registration/login.py
Normal file
0
web/templates/registration/login.py
Normal file
Loading…
x
Reference in New Issue
Block a user