mirror of
https://github.com/th3r00t/pyShelf.git
synced 2026-04-28 01:59:35 -04:00
Phased out nginx in favor of running django under daphne with asgi.
Adjusted the docker image in favor of this, & fixed urls.py which was missing the static request responder.
This commit is contained in:
16
src/frontend/asgi.py
Normal file
16
src/frontend/asgi.py
Normal file
@@ -0,0 +1,16 @@
|
||||
"""
|
||||
ASGI config for asgi project.
|
||||
|
||||
It exposes the ASGI callable as a module-level variable named ``application``.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/3.1/howto/deployment/asgi/
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from django.core.asgi import get_asgi_application
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'frontend.settings')
|
||||
|
||||
application = get_asgi_application()
|
||||
@@ -21,38 +21,36 @@ CUR_DIR = Path.cwd()
|
||||
PRG_DIR = CUR_DIR.parts[0:-1]
|
||||
PRG_DIR = Path(*PRG_DIR)
|
||||
|
||||
|
||||
CONFIG = Config(PRG_DIR)
|
||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
|
||||
# Quick-start development settings - unsuitable for production
|
||||
# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
|
||||
|
||||
# SECURITY WARNING: keep the secret key used in production secret!
|
||||
SECRET_KEY = CONFIG.SECRET
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = TEMPLATE_DEBUG = CONFIG.debug_build_mode
|
||||
|
||||
BUILD_MODE = CONFIG.build_mode
|
||||
if BUILD_MODE == 'debug':
|
||||
DEBUG = TEMPLATE_DEBUG = True
|
||||
else:
|
||||
DEBUG = TEMPLATE_DEBUG = False
|
||||
if DEBUG is True:
|
||||
print("DEBUG build mode is ON")
|
||||
from pudb.remote import set_trace
|
||||
else:
|
||||
print("Production Mode Set")
|
||||
ALLOWED_HOSTS = CONFIG.allowed_hosts
|
||||
|
||||
|
||||
# Application definition
|
||||
|
||||
INSTALLED_APPS = [
|
||||
"django.contrib.admin",
|
||||
"django.contrib.auth",
|
||||
"django.contrib.contenttypes",
|
||||
"django.contrib.sessions",
|
||||
"django.contrib.messages",
|
||||
"django.contrib.staticfiles",
|
||||
"interface",
|
||||
"interface.templatetags",
|
||||
"debug_toolbar",
|
||||
"widget_tweaks"
|
||||
"django.contrib.admin", "django.contrib.auth",
|
||||
"django.contrib.contenttypes", "django.contrib.sessions",
|
||||
"django.contrib.messages", "django.contrib.staticfiles", "interface",
|
||||
"interface.templatetags", "debug_toolbar", "widget_tweaks"
|
||||
]
|
||||
AUTH_USER_MODEL = "interface.User"
|
||||
MIDDLEWARE = [
|
||||
@@ -90,9 +88,9 @@ TEMPLATES = [
|
||||
},
|
||||
]
|
||||
|
||||
WSGI_APPLICATION = "frontend.wsgi.application"
|
||||
|
||||
# WSGI_APPLICATION = "frontend.wsgi.application"
|
||||
|
||||
WSGI_APPLICATION = 'asgi.wsgi.application'
|
||||
# Database
|
||||
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases
|
||||
DATABASES = {
|
||||
@@ -115,14 +113,23 @@ DATABASES = {
|
||||
|
||||
AUTH_PASSWORD_VALIDATORS = [
|
||||
{
|
||||
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
|
||||
"NAME":
|
||||
"django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
|
||||
},
|
||||
{
|
||||
"NAME":
|
||||
"django.contrib.auth.password_validation.MinimumLengthValidator",
|
||||
},
|
||||
{
|
||||
"NAME":
|
||||
"django.contrib.auth.password_validation.CommonPasswordValidator",
|
||||
},
|
||||
{
|
||||
"NAME":
|
||||
"django.contrib.auth.password_validation.NumericPasswordValidator",
|
||||
},
|
||||
{"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",},
|
||||
{"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",},
|
||||
{"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",},
|
||||
]
|
||||
|
||||
|
||||
# Internationalization
|
||||
# https://docs.djangoproject.com/en/2.2/topics/i18n/
|
||||
|
||||
@@ -136,7 +143,6 @@ USE_L10N = True
|
||||
|
||||
USE_TZ = True
|
||||
|
||||
|
||||
# Static files (CSS, JavaScript, Images)
|
||||
# https://docs.djangoproject.com/en/2.2/howto/static-files/
|
||||
LOGIN_REDIRECT_URL = 'home'
|
||||
|
||||
@@ -19,6 +19,7 @@ from django.contrib.auth import views as auth_views
|
||||
from django.contrib.auth.models import User
|
||||
from django.shortcuts import HttpResponse
|
||||
from django.urls import include, path, re_path
|
||||
from django.conf.urls.static import static
|
||||
from interface import views
|
||||
|
||||
urlpatterns = [
|
||||
@@ -67,7 +68,7 @@ urlpatterns = [
|
||||
auth_views.PasswordResetCompleteView.as_view(),
|
||||
name='password_reset_complete',
|
||||
),
|
||||
]
|
||||
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
|
||||
if settings.DEBUG:
|
||||
import debug_toolbar
|
||||
|
||||
|
||||
Reference in New Issue
Block a user