diff --git a/.gitignore b/.gitignore index 2086012..dd81c91 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,6 @@ __pycache__ # Ignore sqlite db *.sqlite3 + +# Ignore private.py since it contains secrets +shorturl/shorturl/private.py diff --git a/shorturl/shorturl/private.py.example b/shorturl/shorturl/private.py.example new file mode 100644 index 0000000..baa966a --- /dev/null +++ b/shorturl/shorturl/private.py.example @@ -0,0 +1,2 @@ +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'REPLACE THIS VALUE BEFORE USING IT IN PRODUCTION' diff --git a/shorturl/shorturl/settings.py b/shorturl/shorturl/settings.py index 0dc3998..1381c7c 100644 --- a/shorturl/shorturl/settings.py +++ b/shorturl/shorturl/settings.py @@ -9,6 +9,8 @@ https://docs.djangoproject.com/en/3.1/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/3.1/ref/settings/ """ +# Import private settings from private.py +from .private import * from pathlib import Path @@ -19,9 +21,6 @@ BASE_DIR = Path(__file__).resolve().parent.parent # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/ -# SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = 'dg0e#z95djls+s_b7o(x8$zc*3%vnr0gy4!8vx#&(9lbw%dwu-' - # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True @@ -54,7 +53,7 @@ ROOT_URLCONF = 'shorturl.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [], + 'DIRS': ['shorturl/templates'], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ diff --git a/shorturl/shorturl/templates/index.html b/shorturl/shorturl/templates/index.html new file mode 100644 index 0000000..8a27475 --- /dev/null +++ b/shorturl/shorturl/templates/index.html @@ -0,0 +1 @@ +Foo! Bar! diff --git a/shorturl/shorturl/urls.py b/shorturl/shorturl/urls.py index f4fc9d0..7c471ea 100644 --- a/shorturl/shorturl/urls.py +++ b/shorturl/shorturl/urls.py @@ -15,7 +15,9 @@ Including another URLconf """ from django.contrib import admin from django.urls import path +from . import views urlpatterns = [ path('admin/', admin.site.urls), + path('', views.index, name='index'), ] diff --git a/shorturl/shorturl/views.py b/shorturl/shorturl/views.py new file mode 100644 index 0000000..8f8eb52 --- /dev/null +++ b/shorturl/shorturl/views.py @@ -0,0 +1,7 @@ +from django.http import HttpResponse +from django.template import loader + +def index(request): + template = loader.get_template('index.html') + context = {} + return HttpResponse(template.render(context, request))