Skip to content

Commit 84c6a9b

Browse files
committed
Projet Django minimal qui proxy Nuxt
ref #1182
1 parent 23648bb commit 84c6a9b

File tree

10 files changed

+665
-0
lines changed

10 files changed

+665
-0
lines changed

django/Procfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: gunicorn core.wsgi --worker-class=gevent --log-file=-

django/bin/post_compile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
3+
./manage.py check --deploy

django/core/__init__.py

Whitespace-only changes.

django/core/settings.py

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
from pathlib import Path
2+
3+
import sentry_sdk
4+
from environ import Env
5+
6+
env = Env()
7+
env.smart_cast = False
8+
9+
sentry_sdk.init(
10+
dsn=env.str("SENTRY_DSN", default=""),
11+
traces_sample_rate=0.1,
12+
)
13+
14+
BASE_DIR = Path(__file__).resolve().parent.parent
15+
16+
17+
# Quick-start development settings - unsuitable for production
18+
# See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/
19+
20+
SECRET_KEY = env.str("SECRET_KEY")
21+
22+
DEBUG = env.str("DEBUG", False)
23+
24+
ALLOWED_HOSTS = env.list("ALLOWED_HOSTS", default=[])
25+
26+
# Application definition
27+
28+
INSTALLED_APPS = [
29+
"django.contrib.admin",
30+
"django.contrib.auth",
31+
"django.contrib.contenttypes",
32+
"django.contrib.sessions",
33+
"django.contrib.messages",
34+
"django.contrib.staticfiles",
35+
"revproxy.apps.RevProxyConfig",
36+
]
37+
38+
MIDDLEWARE = [
39+
"django.middleware.security.SecurityMiddleware",
40+
"django.contrib.sessions.middleware.SessionMiddleware",
41+
"django.middleware.common.CommonMiddleware",
42+
"django.middleware.csrf.CsrfViewMiddleware",
43+
"django.contrib.auth.middleware.AuthenticationMiddleware",
44+
"django.contrib.messages.middleware.MessageMiddleware",
45+
"django.middleware.clickjacking.XFrameOptionsMiddleware",
46+
]
47+
48+
ROOT_URLCONF = "core.urls"
49+
50+
TEMPLATES = [
51+
{
52+
"BACKEND": "django.template.backends.django.DjangoTemplates",
53+
"DIRS": [],
54+
"APP_DIRS": True,
55+
"OPTIONS": {
56+
"context_processors": [
57+
"django.template.context_processors.debug",
58+
"django.template.context_processors.request",
59+
"django.contrib.auth.context_processors.auth",
60+
"django.contrib.messages.context_processors.messages",
61+
],
62+
},
63+
},
64+
]
65+
66+
WSGI_APPLICATION = "core.wsgi.application"
67+
68+
69+
# Password validation
70+
# https://docs.djangoproject.com/en/5.1/ref/settings/#auth-password-validators
71+
72+
AUTH_PASSWORD_VALIDATORS = [
73+
{
74+
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
75+
},
76+
{
77+
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
78+
},
79+
{
80+
"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
81+
},
82+
{
83+
"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
84+
},
85+
]
86+
87+
88+
# Internationalization
89+
# https://docs.djangoproject.com/en/5.1/topics/i18n/
90+
91+
LANGUAGE_CODE = "fr-fr"
92+
93+
TIME_ZONE = "UTC"
94+
95+
USE_I18N = True
96+
97+
USE_TZ = True
98+
99+
100+
# Static files (CSS, JavaScript, Images)
101+
# https://docs.djangoproject.com/en/5.1/howto/static-files/
102+
103+
STATIC_URL = "static/"
104+
105+
# Default primary key field type
106+
# https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field
107+
108+
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
109+
INTERNAL_IPS = ["127.0.0.1"]
110+
111+
# CSRF_COOKIE_SECURE = True
112+
SESSION_COOKIE_SECURE = True
113+
SECURE_SSL_REDIRECT = True
114+
SECURE_HSTS_SECONDS = 31536000
115+
SECURE_HSTS_INCLUDE_SUBDOMAINS = True
116+
SECURE_HSTS_PRELOAD = True
117+
118+
UPSTREAM_NUXT = env.str("UPSTREAM_NUXT")

django/core/urls.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from django.conf import settings
2+
from django.urls import re_path
3+
from revproxy.views import ProxyView
4+
5+
urlpatterns = [
6+
re_path(r"(?P<path>.*)", ProxyView.as_view(upstream=settings.UPSTREAM_NUXT)),
7+
]

django/core/wsgi.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
WSGI config for config project.
3+
4+
It exposes the WSGI callable as a module-level variable named ``application``.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/5.1/howto/deployment/wsgi/
8+
"""
9+
10+
import os
11+
12+
from django.core.wsgi import get_wsgi_application
13+
14+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "core.settings")
15+
16+
application = get_wsgi_application()

django/manage.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env python
2+
"""Django's command-line utility for administrative tasks."""
3+
4+
import os
5+
import sys
6+
7+
8+
def main() -> None:
9+
"""Run administrative tasks."""
10+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "core.settings")
11+
try:
12+
from django.core.management import execute_from_command_line
13+
except ImportError as exc:
14+
msg = (
15+
"Couldn't import Django. Are you sure it's installed and "
16+
"available on your PYTHONPATH environment variable? Did you "
17+
"forget to activate a virtual environment?"
18+
)
19+
raise ImportError(msg) from exc
20+
execute_from_command_line(sys.argv)
21+
22+
23+
if __name__ == "__main__":
24+
main()

django/pyproject.toml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[project]
2+
name = "docurba"
3+
version = "1"
4+
requires-python = ">=3.13"
5+
dependencies = [
6+
"django",
7+
"django-environ",
8+
"django-revproxy",
9+
"gunicorn[gevent]",
10+
"sentry-sdk[django]",
11+
]
12+
13+
[dependency-groups]
14+
dev = ["honcho", "ptpython", "ruff"]
15+
16+
[tool.ruff.lint]
17+
select = ["ALL"]
18+
ignore = [
19+
"COM812", # Missing trailing comma, conflicts with formatter
20+
"D10", # Missing docstring
21+
"E501", # Line too long
22+
]
23+
[tool.ruff.lint.pydocstyle]
24+
# Use Google-style docstrings.
25+
convention = "pep257"

django/requirements.txt

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# This file was autogenerated by uv via the following command:
2+
# uv export --no-dev --output-file requirements.txt
3+
asgiref==3.8.1 \
4+
--hash=sha256:3e1e3ecc849832fe52ccf2cb6686b7a55f82bb1d6aee72a58826471390335e47 \
5+
--hash=sha256:c343bd80a0bec947a9860adb4c432ffa7db769836c64238fc34bdc3fec84d590
6+
certifi==2025.1.31 \
7+
--hash=sha256:3d5da6925056f6f18f119200434a4780a94263f10d1c21d032a6f6b2baa20651 \
8+
--hash=sha256:ca78db4565a652026a4db2bcdf68f2fb589ea80d0be70e03929ed730746b84fe
9+
cffi==1.17.1 ; platform_python_implementation == 'CPython' and sys_platform == 'win32' \
10+
--hash=sha256:1c39c6016c32bc48dd54561950ebd6836e1670f2ae46128f67cf49e789c52824 \
11+
--hash=sha256:e03eab0a8677fa80d646b5ddece1cbeaf556c313dcfac435ba11f107ba117b5d \
12+
--hash=sha256:f6a16c31041f09ead72d69f583767292f750d24913dadacf5756b966aacb3f1a
13+
django==5.1.5 \
14+
--hash=sha256:19bbca786df50b9eca23cee79d495facf55c8f5c54c529d9bf1fe7b5ea086af3 \
15+
--hash=sha256:c46eb936111fffe6ec4bc9930035524a8be98ec2f74d8a0ff351226a3e52f459
16+
django-environ==0.12.0 \
17+
--hash=sha256:227dc891453dd5bde769c3449cf4a74b6f2ee8f7ab2361c93a07068f4179041a \
18+
--hash=sha256:92fb346a158abda07ffe6eb23135ce92843af06ecf8753f43adf9d2366dcc0ca
19+
django-revproxy==0.13.0 \
20+
--hash=sha256:6130d52d5042624c918134369be0a825e9f7e87d15e12b739d6666e5ed1f32ef
21+
gevent==24.11.1 \
22+
--hash=sha256:1ea50009ecb7f1327347c37e9eb6561bdbc7de290769ee1404107b9a9cba7cf1 \
23+
--hash=sha256:2142704c2adce9cd92f6600f371afb2860a446bfd0be5bd86cca5b3e12130766 \
24+
--hash=sha256:356b73d52a227d3313f8f828025b665deada57a43d02b1cf54e5d39028dbcf8d \
25+
--hash=sha256:58851f23c4bdb70390f10fc020c973ffcf409eb1664086792c8b1e20f25eef43 \
26+
--hash=sha256:8bd1419114e9e4a3ed33a5bad766afff9a3cf765cb440a582a1b3a9bc80c1aca \
27+
--hash=sha256:92e0d7759de2450a501effd99374256b26359e801b2d8bf3eedd3751973e87f5 \
28+
--hash=sha256:ca845138965c8c56d1550499d6b923eb1a2331acfa9e13b817ad8305dde83d11 \
29+
--hash=sha256:d618e118fdb7af1d6c1a96597a5cd6ac84a9f3732b5be8515c6a66e098d498b6 \
30+
--hash=sha256:ec68e270543ecd532c4c1d70fca020f90aa5486ad49c4f3b8b2e64a66f5c9274
31+
greenlet==3.1.1 ; platform_python_implementation == 'CPython' \
32+
--hash=sha256:0153404a4bb921f0ff1abeb5ce8a5131da56b953eda6e14b88dc6bbc04d2049e \
33+
--hash=sha256:04b013dc07c96f83134b1e99888e7a79979f1a247e2a9f59697fa14b5862ed01 \
34+
--hash=sha256:05175c27cb459dcfc05d026c4232f9de8913ed006d42713cb8a5137bd49375f1 \
35+
--hash=sha256:275f72decf9932639c1c6dd1013a1bc266438eb32710016a1c742df5da6e60a1 \
36+
--hash=sha256:411f015496fec93c1c8cd4e5238da364e1da7a124bcb293f085bf2860c32c6f6 \
37+
--hash=sha256:4ce3ac6cdb6adf7946475d7ef31777c26d94bccc377e070a7986bd2d5c515467 \
38+
--hash=sha256:4ead44c85f8ab905852d3de8d86f6f8baf77109f9da589cb4fa142bd3b57b475 \
39+
--hash=sha256:6510bf84a6b643dabba74d3049ead221257603a253d0a9873f55f6a59a65f822 \
40+
--hash=sha256:667a9706c970cb552ede35aee17339a18e8f2a87a51fba2ed39ceeeb1004798a \
41+
--hash=sha256:7876452af029456b3f3549b696bb36a06db7c90747740c5302f74a9e9fa14b13 \
42+
--hash=sha256:8320f64b777d00dd7ccdade271eaf0cad6636343293a25074cc5566160e4de7b \
43+
--hash=sha256:935e943ec47c4afab8965954bf49bfa639c05d4ccf9ef6e924188f762145c0ff \
44+
--hash=sha256:b42703b1cf69f2aa1df7d1030b9d77d3e584a70755674d60e710f0af570f3761 \
45+
--hash=sha256:b8a678974d1f3aa55f6cc34dc480169d58f2e6d8958895d68845fa4ab566509e \
46+
--hash=sha256:c4aab7f6381f38a4b42f269057aee279ab0fc7bf2e929e3d4abfae97b682a12c \
47+
--hash=sha256:efc0f674aa41b92da8c49e0346318c6075d734994c3c4e4430b1c3f853e498e4 \
48+
--hash=sha256:f1695e76146579f8c06c1509c7ce4dfe0706f49c6831a817ac04eebb2fd02011
49+
gunicorn==23.0.0 \
50+
--hash=sha256:ec400d38950de4dfd418cff8328b2c8faed0edb0d517d3394e457c317908ca4d \
51+
--hash=sha256:f014447a0101dc57e294f6c18ca6b40227a4c90e9bdb586042628030cba004ec
52+
packaging==24.2 \
53+
--hash=sha256:09abb1bccd265c01f4a3aa3f7a7db064b36514d2cba19a2f694fe6150451a759 \
54+
--hash=sha256:c228a6dc5e932d346bc5739379109d49e8853dd8223571c7c5b55260edc0b97f
55+
pycparser==2.22 ; platform_python_implementation == 'CPython' and sys_platform == 'win32' \
56+
--hash=sha256:491c8be9c040f5390f5bf44a5b07752bd07f56edf992381b05c701439eec10f6 \
57+
--hash=sha256:c3702b6d3dd8c7abc1afa565d7e63d53a1d0bd86cdc24edd75470f4de499cfcc
58+
sentry-sdk==2.22.0 \
59+
--hash=sha256:3d791d631a6c97aad4da7074081a57073126c69487560c6f8bffcf586461de66 \
60+
--hash=sha256:b4bf43bb38f547c84b2eadcefbe389b36ef75f3f38253d7a74d6b928c07ae944
61+
setuptools==75.8.1 \
62+
--hash=sha256:3bc32c0b84c643299ca94e77f834730f126efd621de0cc1de64119e0e17dab1f \
63+
--hash=sha256:65fb779a8f28895242923582eadca2337285f0891c2c9e160754df917c3d2530
64+
sqlparse==0.5.3 \
65+
--hash=sha256:09f67787f56a0b16ecdbde1bfc7f5d9c3371ca683cfeaa8e6ff60b4807ec9272 \
66+
--hash=sha256:cf2196ed3418f3ba5de6af7e82c694a9fbdbfecccdfc72e281548517081f16ca
67+
tzdata==2025.1 ; sys_platform == 'win32' \
68+
--hash=sha256:24894909e88cdb28bd1636c6887801df64cb485bd593f2fd83ef29075a81d694 \
69+
--hash=sha256:7e127113816800496f027041c570f50bcd464a020098a3b6b199517772303639
70+
urllib3==2.3.0 \
71+
--hash=sha256:1cee9ad369867bfdbbb48b7dd50374c0967a0bb7710050facf0dd6911440e3df \
72+
--hash=sha256:f8c5449b3cf0861679ce7e0503c7b44b5ec981bec0d1d3795a07f1ba96f0204d
73+
zope-event==5.0 \
74+
--hash=sha256:2832e95014f4db26c47a13fdaef84cef2f4df37e66b59d8f1f4a8f319a632c26 \
75+
--hash=sha256:bac440d8d9891b4068e2b5a2c5e2c9765a9df762944bda6955f96bb9b91e67cd
76+
zope-interface==7.2 \
77+
--hash=sha256:15398c000c094b8855d7d74f4fdc9e73aa02d4d0d5c775acdef98cdb1119768d \
78+
--hash=sha256:3e0350b51e88658d5ad126c6a57502b19d5f559f6cb0a628e3dc90442b53dd98 \
79+
--hash=sha256:4893395d5dd2ba655c38ceb13014fd65667740f09fa5bb01caa1e6284e48c0cd \
80+
--hash=sha256:802176a9f99bd8cc276dcd3b8512808716492f6f557c11196d42e26c01a69a4c \
81+
--hash=sha256:8b49f1a3d1ee4cdaf5b32d2e738362c7f5e40ac8b46dd7d1a65e82a4872728fe \
82+
--hash=sha256:a71a5b541078d0ebe373a81a3b7e71432c61d12e660f1d67896ca62d9628045b \
83+
--hash=sha256:eb23f58a446a7f09db85eda09521a498e109f137b85fb278edb2e34841055398

0 commit comments

Comments
 (0)