diff --git a/.vscode/launch.json b/.vscode/launch.json index bc52e5e..d070863 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -8,7 +8,7 @@ "program": "${workspaceFolder}/manage.py", "args": [ "runserver", - "--noreload", + "--reload", "--nothreading" ], "django": true, diff --git a/config/settings.py b/config/settings.py index 47326b0..4883d2c 100644 --- a/config/settings.py +++ b/config/settings.py @@ -70,6 +70,7 @@ INSTALLED_APPS: list[str] = [ "django.contrib.sessions", "django.contrib.messages", "django.contrib.staticfiles", + "ninja", ] MIDDLEWARE: list[str] = [ @@ -130,3 +131,26 @@ STORAGES: dict[str, dict[str, str]] = { "BACKEND": "whitenoise.storage.CompressedManifestStaticFilesStorage", }, } + +LOGGING = { + "version": 1, + "disable_existing_loggers": False, + "handlers": { + "console": { + "level": "DEBUG", + "class": "logging.StreamHandler", + }, + }, + "loggers": { + "": { + "handlers": ["console"], + "level": "DEBUG", + "propagate": True, + }, + "django.utils.autoreload": { # Remove spam + "handlers": ["console"], + "level": "INFO", + "propagate": True, + }, + }, +} diff --git a/config/urls.py b/config/urls.py index df572f3..b6ccf6b 100644 --- a/config/urls.py +++ b/config/urls.py @@ -1,10 +1,21 @@ from django.contrib import admin -from django.urls import include, path +from django.urls import URLPattern, include, path from django.urls.resolvers import URLResolver +from ninja import NinjaAPI + +from twitch.api import router as twitch_router + +api = NinjaAPI( + title="TTVDrops API", + version="1.0.0", + description="No rate limits, but don't abuse it.", +) +api.add_router(prefix="/twitch", router=twitch_router) app_name: str = "config" -urlpatterns: list[URLResolver] = [ +urlpatterns: list[URLPattern | URLResolver] = [ path(route="admin/", view=admin.site.urls), path(route="", view=include(arg="core.urls")), + path(route="api/", view=api.urls), ] diff --git a/core/templates/base.html b/core/templates/base.html deleted file mode 100644 index b105fc4..0000000 --- a/core/templates/base.html +++ /dev/null @@ -1,120 +0,0 @@ -{% load static %} - - - - - - - - - {% block title %} - Twitch drops - {% endblock title %} - - - - {% if messages %} - - {% endif %} - -

- TTVDrop -

-
- -
-
- {% block content %}{% endblock %} -
-
- - - diff --git a/core/templates/index.html b/core/templates/index.html index 04814d2..15808b8 100644 --- a/core/templates/index.html +++ b/core/templates/index.html @@ -93,13 +93,35 @@ font-weight: 600; margin: 0; } + + /* Django messages framework */ + .messages { + list-style-type: none; + } + + /* Make error messages red and success messages green */ + .error { + color: red; + } + .success { + color: green; + } + + {% if messages %} + + {% endif %}

Twitch Drops

{% for organization, org_data in orgs_data.items %}