diff --git a/trafficlightfrontend/static/trafficlightfrontend/amber-right.png b/trafficlightfrontend/static/trafficlightfrontend/amber-right.png new file mode 100644 index 0000000..22cc2a6 Binary files /dev/null and b/trafficlightfrontend/static/trafficlightfrontend/amber-right.png differ diff --git a/trafficlightfrontend/static/trafficlightfrontend/amber.png b/trafficlightfrontend/static/trafficlightfrontend/amber.png new file mode 100644 index 0000000..f19c699 Binary files /dev/null and b/trafficlightfrontend/static/trafficlightfrontend/amber.png differ diff --git a/trafficlightfrontend/static/trafficlightfrontend/green-right.png b/trafficlightfrontend/static/trafficlightfrontend/green-right.png new file mode 100644 index 0000000..94c4f88 Binary files /dev/null and b/trafficlightfrontend/static/trafficlightfrontend/green-right.png differ diff --git a/trafficlightfrontend/static/trafficlightfrontend/green.png b/trafficlightfrontend/static/trafficlightfrontend/green.png new file mode 100644 index 0000000..c9ef5c6 Binary files /dev/null and b/trafficlightfrontend/static/trafficlightfrontend/green.png differ diff --git a/trafficlightfrontend/static/trafficlightfrontend/red-right.png b/trafficlightfrontend/static/trafficlightfrontend/red-right.png new file mode 100644 index 0000000..0dfad1b Binary files /dev/null and b/trafficlightfrontend/static/trafficlightfrontend/red-right.png differ diff --git a/trafficlightfrontend/static/trafficlightfrontend/red.png b/trafficlightfrontend/static/trafficlightfrontend/red.png new file mode 100644 index 0000000..5d725b8 Binary files /dev/null and b/trafficlightfrontend/static/trafficlightfrontend/red.png differ diff --git a/trafficlightfrontend/templates/trafficlightfrontend/index.html b/trafficlightfrontend/templates/trafficlightfrontend/index.html new file mode 100644 index 0000000..6870e86 --- /dev/null +++ b/trafficlightfrontend/templates/trafficlightfrontend/index.html @@ -0,0 +1,112 @@ + + + Traffic Light Simmulation Frontend + + +

Traffic light demo:

+

Status: Awaiting first update...

+

Period: Awaiting first update...

+

Time: Awaiting first update...

+
+
+
+
NORTH
+
+
+
+
+
+
+
WEST
+
+
+
+
+
+
EAST
+
+
+
+
+
SOUTH
+
+
+
+
+
+ + + diff --git a/trafficlightfrontend/urls.py b/trafficlightfrontend/urls.py index d3136bd..3eea29e 100644 --- a/trafficlightfrontend/urls.py +++ b/trafficlightfrontend/urls.py @@ -3,5 +3,6 @@ from django.urls import path from . import views urlpatterns = [ - path("", views.index, name="index") + path("", views.index, name="index"), + path("status/", views.status, name="status"), ] diff --git a/trafficlightfrontend/views.py b/trafficlightfrontend/views.py index 88040c3..3cba637 100644 --- a/trafficlightfrontend/views.py +++ b/trafficlightfrontend/views.py @@ -1,6 +1,11 @@ -from django.http import HttpResponse from django.shortcuts import render +from django.http import JsonResponse +from simulation import SimulationThread + -# Create your views here. def index(request): - return HttpResponse("Basic test response.") + return render(request, "trafficlightfrontend/index.html") + + +def status(request): + return JsonResponse(SimulationThread.get_instance().get_snapshot())