Skip to content

Commit 80e766b

Browse files
committed
adding host info page
1 parent 0b69b15 commit 80e766b

File tree

4 files changed

+97
-1
lines changed

4 files changed

+97
-1
lines changed

src/django_project/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,5 +296,5 @@
296296
PROJECT_DESCRIPTION = (
297297
"""spokane_python is a super awesome project powered, in part, by amazing code provided by DjangoAddicts."""
298298
)
299-
PROJECT_VERSION = env.str("PROJECT_VERSION", "0.0.1")
299+
PROJECT_VERSION = env.str("IMAGE_TAG", "0.0.0")
300300
PROJECT_SOURCE = "https://github.com/SpokaneTech/SpokanePythonWeb"
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
{% load static %}
2+
3+
<!DOCTYPE html>
4+
<html lang="en">
5+
6+
<head>
7+
<!-- Google tag (gtag.js) -->
8+
<script async src="https://www.googletagmanager.com/gtag/js?id=G-X6VK8H1VLF"></script>
9+
<script>
10+
window.dataLayer = window.dataLayer || [];
11+
function gtag(){dataLayer.push(arguments);}
12+
gtag('js', new Date());
13+
14+
gtag('config', 'G-X6VK8H1VLF');
15+
</script>
16+
<meta charset="UTF-8">
17+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
18+
<meta name="description"
19+
content="Spokane's premiere local Python user group. Join us for meetups, workshops, and community events to learn and grow in Python programming.">
20+
<meta name="keywords" content="spokane, spokanetech, python, coding, software, developers, tech, technology">
21+
<meta property="og:title" content="Spokane Python User Group">
22+
<meta property="og:description"
23+
content="Spokane's premiere local Python user group. Join us for meetups, workshops, and community events to learn and grow in Python programming.">
24+
<meta name="robots" content="noindex, nofollow">
25+
<link rel="icon" type="image/png" sizes="16x16" href="{% static 'spokanepython/img/favicon.png' %}">
26+
27+
<title>Spokane Python User Group</title>
28+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css">
29+
<link rel="stylesheet" href="{% static 'spokanepython/css/spug.css' %}">
30+
31+
</head>
32+
33+
<body>
34+
<section id="hero" class="p-5 d-flex justify-content-center" style="min-height: 100vh; background: linear-gradient(135deg, #3776AB 0%, #103069 100%);">
35+
<div class="container text-center p-2">
36+
<h1 class="display-3 text-white fw-bold"><span class="text-warning"><i class="fa-brands fa-python me-2"></i></span></h1>
37+
<h1 class="display-3 text-warning fw-bold"><span class="">Spokane Python User Group</span></h1>
38+
<!-- <h3 class="fw-bold text-warning py-3">Host Information</h3> -->
39+
<p class="my-4 lead fw-bold text-white">This page provides information about the host system running this application.</p>
40+
<div class="my-5">
41+
<div class="row mb-4">
42+
<span class="text-warning fw-bold">Start Time:</span>
43+
<span class="text-light">{{ HH_STARTTIME }}</span>
44+
</div>
45+
<div class="row mb-4">
46+
<span class="text-warning fw-bold">Version</span>
47+
<span class="text-light">{{ PROJECT_VERSION }}</span>
48+
</div>
49+
<div class="row mb-4">
50+
<span class="text-warning fw-bold">Python Version:</span>
51+
<span class="text-light">{{ python_version }}</span>
52+
</div>
53+
<div class="row mb-4">
54+
<span class="text-warning fw-bold">Django Version:</span>
55+
<span class="text-light">{{ django_version }}</span>
56+
</div>
57+
<div class="row mb-4">
58+
<span class="text-warning fw-bold">Hostname:</span>
59+
<span class="text-light">{{ hostname }}</span>
60+
</div>
61+
<div class="row mb-4">
62+
<span class="text-warning fw-bold">Source Code:</span>
63+
<span class="text-light"><a href="{{ source_code }}" target="_blank" class="text-light">{{ source_code }}</a></span>
64+
</div>
65+
<div class="row mb-4">
66+
<span class="text-warning fw-bold">Client IP Address:</span>
67+
<span class="text-light">{{ remote_ip_address }}</span>
68+
</div>
69+
<div class="row mb-4">
70+
<span class="text-warning fw-bold">Client User Agent:</span>
71+
<span class="text-light">{{ user_agent }}</span>
72+
</div>
73+
</div>
74+
</div>
75+
</section>
76+
</body>
77+
</html>

src/django_project/web/urls/gui.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from django.urls import path
2+
23
from web.views import gui
34

45
urlpatterns = [
@@ -7,6 +8,7 @@
78
path("index/", gui.IndexView.as_view(), name="index"),
89
path("default/", gui.IndexView.as_view(), name="default"),
910
path("home/", gui.IndexView.as_view(), name="home"),
11+
path("host/", gui.HostView.as_view(), name="host_info"),
1012
# HTMX views
1113
path("htmx/resource-list/<int:pk>/", gui.ResourceListPartialView.as_view(), name="htmx_resource_list"),
1214
path("htmx/past-events/", gui.PastEventsPartialView.as_view(), name="htmx_past_events"),

src/django_project/web/views/gui.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1+
import sys
12
from typing import Any
23

4+
import django
5+
from django.conf import settings
36
from django.db.models.manager import BaseManager
47
from django.http import HttpResponse
58
from django.shortcuts import render
69
from django.utils import timezone
710
from django.views import View
811
from django.views.generic import TemplateView
912
from handyhelpers.views.htmx import HtmxFormPostSimple, HtmxPartialView
13+
1014
from web.forms import PresentationRequestForm, TopicSuggestionForm
1115
from web.models import Event, Resource, ResourceCategory
1216

@@ -15,6 +19,19 @@ class IndexView(TemplateView):
1519
template_name = "web/full/index.html"
1620

1721

22+
class HostView(View):
23+
def get(self, request) -> HttpResponse:
24+
host_info: dict[str, str] = {
25+
"hostname": request.get_host(),
26+
"remote_ip_address": request.META.get("REMOTE_ADDR", "Unknown"),
27+
"user_agent": request.META.get("HTTP_USER_AGENT", "Unknown"),
28+
"source_code": getattr(settings, "PROJECT_SOURCE", "Unknown"),
29+
"python_version": f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}",
30+
"django_version": django.get_version(),
31+
}
32+
return render(request, "web/full/host_info.html", host_info)
33+
34+
1835
class ResourceListPartialView(View):
1936
def get(self, request, pk) -> HttpResponse:
2037
category: Any = ResourceCategory.objects.get_object_or_none(pk=pk)

0 commit comments

Comments
 (0)