v0.0.00.5
This commit is contained in:
parent
62232fd75a
commit
6803a3ab82
@ -1,4 +1,4 @@
|
||||
FROM nvidia/cuda:12.8.0-cudnn-runtime-ubuntu22.04
|
||||
FROM ubuntu:22.04
|
||||
|
||||
# Системные зависимости
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
@ -17,7 +17,7 @@ WORKDIR /app/web
|
||||
|
||||
# requirements
|
||||
COPY requirements/requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements-gpu-cuda128.txt
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
# Копируем всё
|
||||
# всё из web/ — включая models, app, etc.
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
FROM nvidia/cuda:12.8.0-cudnn-runtime-ubuntu22.04
|
||||
FROM nvidia/cuda:12.6.0-cudnn-runtime-ubuntu22.04
|
||||
|
||||
# Системные зависимости
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
@ -17,7 +17,7 @@ WORKDIR /app/web
|
||||
|
||||
# requirements
|
||||
COPY requirements/requirements-gpu-cuda126.txt .
|
||||
RUN pip install --no-cache-dir -r requirements-gpu-cuda128.txt
|
||||
RUN pip install --no-cache-dir -r requirements-gpu-cuda126.txt
|
||||
|
||||
# Копируем всё
|
||||
# всё из web/ — включая models, app, etc.
|
||||
|
||||
@ -61,8 +61,8 @@ MIDDLEWARE = [
|
||||
|
||||
]
|
||||
|
||||
LOGIN_URL = '/login/'
|
||||
LOGIN_REDIRECT_URL = '/'
|
||||
LOGIN_URL = '/streaming/login/'
|
||||
LOGIN_REDIRECT_URL = '/streaming/'
|
||||
|
||||
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
|
||||
|
||||
|
||||
@ -21,8 +21,9 @@ 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('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('login/', include("streaming.urls")),
|
||||
path('streaming/', include("streaming.urls"))
|
||||
]
|
||||
|
||||
BIN
web/db.sqlite3
BIN
web/db.sqlite3
Binary file not shown.
16
web/streaming/templates/login.html
Normal file
16
web/streaming/templates/login.html
Normal file
@ -0,0 +1,16 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Login</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Login</h2>
|
||||
{% if error %}<p style="color:red;">{{ error }}</p>{% endif %}
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
<label>Username:</label><input type="text" name="username"><br>
|
||||
<label>Password:</label><input type="password" name="password"><br>
|
||||
<input type="submit" value="Login">
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
@ -2,5 +2,7 @@ from django.urls import path
|
||||
from . import views
|
||||
|
||||
urlpatterns = [
|
||||
path('', views.stream_view, name='stream'),
|
||||
path('login/', views.login_view, name='login'),
|
||||
path('logout/', views.logout_view, name='logout'),
|
||||
path('', views.stream_view, name='stream'),
|
||||
]
|
||||
@ -1,7 +1,11 @@
|
||||
from django.shortcuts import render
|
||||
from django.shortcuts import render, redirect
|
||||
from django.conf import settings
|
||||
from .models import DetectionHistory
|
||||
from django.contrib.auth import authenticate, login, logout
|
||||
from django.views.decorators.csrf import csrf_protect
|
||||
from django.contrib.auth.decorators import login_required
|
||||
|
||||
@login_required
|
||||
def stream_view(request):
|
||||
history = DetectionHistory.objects.all()[:20]
|
||||
return render(request, 'streaming/stream.html',{
|
||||
@ -10,4 +14,24 @@ def stream_view(request):
|
||||
})
|
||||
|
||||
|
||||
@csrf_protect
|
||||
def login_view(request):
|
||||
if request.method == 'POST':
|
||||
username = request.POST.get('username')
|
||||
password = request.POST.get('password')
|
||||
user = authenticate(request, username=username, password=password)
|
||||
if user:
|
||||
login(request, user)
|
||||
return redirect('stream')
|
||||
else:
|
||||
return render(request, 'login.html', {'error': 'Неверный логин или пароль'})
|
||||
return render(request, 'login.html')
|
||||
|
||||
def logout_view(request):
|
||||
logout(request)
|
||||
return redirect('login')
|
||||
|
||||
# @login_required
|
||||
# def home_view(request):
|
||||
# return render(request, 'streaming/stream.html')
|
||||
|
||||
|
||||
@ -1,30 +0,0 @@
|
||||
{% 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>
|
||||
Loading…
x
Reference in New Issue
Block a user