Skip to content

Commit eb85f69

Browse files
committed
main
adding django
1 parent b7ee5ac commit eb85f69

25 files changed

+285
-0
lines changed

db.sqlite3

Whitespace-only changes.

frontend/__init__.py

Whitespace-only changes.
160 Bytes
Binary file not shown.
2.71 KB
Binary file not shown.
1.18 KB
Binary file not shown.
496 Bytes
Binary file not shown.
650 Bytes
Binary file not shown.

frontend/asgi.py

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

frontend/db.sqlite3

Whitespace-only changes.

frontend/my_app/__init__.py

Whitespace-only changes.

frontend/my_app/admin.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.contrib import admin
2+
3+
# Register your models here.

frontend/my_app/apps.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from django.apps import AppConfig
2+
3+
4+
class MyAppConfig(AppConfig):
5+
default_auto_field = 'django.db.models.BigAutoField'
6+
name = 'my_app'

frontend/my_app/migrations/__init__.py

Whitespace-only changes.

frontend/my_app/models.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.db import models
2+
3+
# Create your models here.

frontend/my_app/tests.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.test import TestCase
2+
3+
# Create your tests here.

frontend/my_app/views.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.shortcuts import render
2+
3+
# Create your views here.

frontend/settings.py

+128
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
"""
2+
Django settings for frontend project.
3+
4+
Generated by 'django-admin startproject' using Django 5.0.6.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/5.0/topics/settings/
8+
9+
For the full list of settings and their values, see
10+
https://docs.djangoproject.com/en/5.0/ref/settings/
11+
"""
12+
13+
from pathlib import Path
14+
from configparser import ConfigParser
15+
16+
config = ConfigParser()
17+
config.read("config.ini")
18+
19+
SECRET = config["app"]["SECRET_KEY"]
20+
21+
# Build paths inside the project like this: BASE_DIR / 'subdir'.
22+
BASE_DIR = Path(__file__).resolve().parent.parent
23+
PROJECT_PATH = Path(f"{BASE_DIR}/frontend/templates")
24+
25+
# Quick-start development settings - unsuitable for production
26+
# See https://docs.djangoproject.com/en/5.0/howto/deployment/checklist/
27+
28+
# SECURITY WARNING: keep the secret key used in production secret!
29+
# SECRET_KEY = 'django-insecure-vz)djre2c^lpe5um0m9+amdks!q14m-a2pxe4ym!idt*tchdwl'
30+
SECRET_KEY = SECRET
31+
32+
DEBUG = False
33+
34+
ALLOWED_HOSTS = ["python-speedtest.azurewebsites.net"]
35+
36+
# Application definition
37+
38+
INSTALLED_APPS = [
39+
'django.contrib.admin',
40+
'django.contrib.auth',
41+
'django.contrib.contenttypes',
42+
'django.contrib.sessions',
43+
'django.contrib.messages',
44+
'django.contrib.staticfiles',
45+
]
46+
47+
MIDDLEWARE = [
48+
'django.middleware.security.SecurityMiddleware',
49+
'django.contrib.sessions.middleware.SessionMiddleware',
50+
'django.middleware.common.CommonMiddleware',
51+
'django.middleware.csrf.CsrfViewMiddleware',
52+
'django.contrib.auth.middleware.AuthenticationMiddleware',
53+
'django.contrib.messages.middleware.MessageMiddleware',
54+
'django.middleware.clickjacking.XFrameOptionsMiddleware',
55+
]
56+
57+
ROOT_URLCONF = 'frontend.urls'
58+
59+
TEMPLATES = [
60+
{
61+
'BACKEND': 'django.template.backends.django.DjangoTemplates',
62+
'DIRS': [PROJECT_PATH],
63+
'APP_DIRS': True,
64+
'OPTIONS': {
65+
'context_processors': [
66+
'django.template.context_processors.debug',
67+
'django.template.context_processors.request',
68+
'django.contrib.auth.context_processors.auth',
69+
'django.contrib.messages.context_processors.messages',
70+
],
71+
},
72+
},
73+
]
74+
75+
WSGI_APPLICATION = 'frontend.wsgi.application'
76+
77+
78+
# Database
79+
# https://docs.djangoproject.com/en/5.0/ref/settings/#databases
80+
81+
DATABASES = {
82+
'default': {
83+
'ENGINE': 'django.db.backends.sqlite3',
84+
'NAME': BASE_DIR / 'db.sqlite3',
85+
}
86+
}
87+
88+
89+
# Password validation
90+
# https://docs.djangoproject.com/en/5.0/ref/settings/#auth-password-validators
91+
92+
AUTH_PASSWORD_VALIDATORS = [
93+
{
94+
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
95+
},
96+
{
97+
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
98+
},
99+
{
100+
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
101+
},
102+
{
103+
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
104+
},
105+
]
106+
107+
108+
# Internationalization
109+
# https://docs.djangoproject.com/en/5.0/topics/i18n/
110+
111+
LANGUAGE_CODE = 'en-us'
112+
113+
TIME_ZONE = 'UTC'
114+
115+
USE_I18N = True
116+
117+
USE_TZ = True
118+
119+
120+
# Static files (CSS, JavaScript, Images)
121+
# https://docs.djangoproject.com/en/5.0/howto/static-files/
122+
123+
STATIC_URL = 'static/'
124+
125+
# Default primary key field type
126+
# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field
127+
128+
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

frontend/templates/about.html

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{% extends 'base.html' %}
2+
3+
{% block title %}About{% endblock %}
4+
5+
{% block content %}
6+
<h1>About</h1>
7+
{% endblock %}

frontend/templates/base.html

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!-- templates/base.html -->
2+
<!DOCTYPE html>
3+
<html>
4+
<head>
5+
<meta charset="utf-8" \>
6+
<title>{% block title %}Speed Test{% endblock %}</title>
7+
</head>
8+
<body>
9+
{% include 'components/navigation.html' %}
10+
<main>
11+
{% block content %}
12+
{% endblock %}
13+
</main>
14+
</body>
15+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<nav>
2+
<ul>
3+
{% url 'index' as index_url %}
4+
<li>{% if request.path == index_url %}Home
5+
{% else %}
6+
<a href="{% url 'index' %}">Home</a>
7+
{% endif %}
8+
</li>
9+
{% url 'about' as about_url %}
10+
<li>{% if request.path == about_url %}About
11+
{% else %}
12+
<a href="{% url 'about' %}">About</a>
13+
{% endif %}
14+
</li>
15+
</ul>
16+
</nav>

frontend/templates/index.html

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{% extends 'base.html' %}
2+
3+
{% block title %}Home{% endblock %}
4+
5+
{% block content %}
6+
<h1>Speed Test</h1>
7+
<p>Basic webpage setup for speed test site.</p>
8+
{% endblock %}

frontend/urls.py

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
"""
2+
URL configuration for frontend project.
3+
4+
The `urlpatterns` list routes URLs to views. For more information please see:
5+
https://docs.djangoproject.com/en/5.0/topics/http/urls/
6+
Examples:
7+
Function views
8+
1. Add an import: from my_app import views
9+
2. Add a URL to urlpatterns: path('', views.home, name='home')
10+
Class-based views
11+
1. Add an import: from other_app.views import Home
12+
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
13+
Including another URLconf
14+
1. Import the include() function: from django.urls import include, path
15+
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
16+
"""
17+
from django.contrib import admin
18+
from django.urls import path
19+
20+
from . import views
21+
22+
urlpatterns = [
23+
path('admin/', admin.site.urls),
24+
path('', views.index, name="index"),
25+
path('about', views.about, name="about"),
26+
]

frontend/views.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# from django.http import HttpResponse
2+
# from django.template import loader
3+
from django.shortcuts import render
4+
5+
def index(request):
6+
# context is how you would pass data into the template
7+
return render(request, 'index.html')
8+
# template = loader.get_template('index.html')
9+
10+
# return HttpResponse(template.render({}, request))
11+
12+
def about(request):
13+
return render(request, 'about.html')

frontend/wsgi.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
WSGI config for frontend 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.0/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', 'frontend.settings')
15+
16+
application = get_wsgi_application()

manage.py

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

0 commit comments

Comments
 (0)