updated poc front end

This commit is contained in:
zman 2023-11-30 17:26:15 -05:00
parent f840331e57
commit 095628567c
5 changed files with 43 additions and 6 deletions

View File

@ -1,9 +1,6 @@
# Use an official nginx image # Use an official nginx image
FROM nginx:alpine FROM nginx:alpine
# Copy the static content into the Nginx server
COPY . /usr/share/nginx/html
# Expose port 80 # Expose port 80
EXPOSE 80 EXPOSE 80

View File

@ -1,10 +1,33 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<title>Hello World Client</title> <title>Simple Frontend</title>
<script>
function fetchData() {
fetch('http://localhost:8000/games')
.then(response => response.json())
.then(data => {
// Assuming 'data' is an array of games
const display = document.getElementById('data-display');
display.innerHTML = ''; // Clear previous content
data.forEach(game => {
const listItem = document.createElement('li');
listItem.textContent = game.name; // Modify as per your data structure
display.appendChild(listItem);
});
})
.catch(error => {
console.error('Error:', error);
document.getElementById('data-display').textContent = 'Error loading data';
});
}
</script>
</head> </head>
<body> <body>
<h1>Hello World from Client</h1> <h1>Welcome to the Proof of Concept Frontend</h1>
<button onclick="fetchData()">Fetch Data from Backend</button>
<div id="data-display"> <!-- Data will be displayed here -->
<!-- Fetched data will be inserted here -->
</div>
</body> </body>
</html> </html>

View File

@ -16,6 +16,8 @@ services:
build: ./client build: ./client
ports: ports:
- "3000:80" - "3000:80"
volumes:
- ./client:/usr/share/nginx/html
depends_on: depends_on:
- backend - backend

Binary file not shown.

View File

@ -25,6 +25,19 @@ SECRET_KEY = "django-insecure-^^r9o7z%c(x51odhohd_a5k7v%1gh@2-br!g_x450+27i_2h-n
# SECURITY WARNING: don't run with debug turned on in production! # SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True DEBUG = True
# SECURITY WARNING: update this when you have the production host
CORS_ALLOW_ALL_ORIGINS = True
CORS_ALLOW_METHODS = [
"DELETE",
"GET",
"OPTIONS",
"PATCH",
"POST",
"PUT",
]
ALLOWED_HOSTS = ["0.0.0.0" ,"localhost", "127.0.0.1"] ALLOWED_HOSTS = ["0.0.0.0" ,"localhost", "127.0.0.1"]
@ -39,11 +52,13 @@ INSTALLED_APPS = [
"django.contrib.staticfiles", "django.contrib.staticfiles",
"rest_framework", "rest_framework",
"server", "server",
"corsheaders",
] ]
MIDDLEWARE = [ MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware", "django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware", "django.contrib.sessions.middleware.SessionMiddleware",
"corsheaders.middleware.CorsMiddleware",
"django.middleware.common.CommonMiddleware", "django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware", "django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware", "django.contrib.auth.middleware.AuthenticationMiddleware",