From 4e5b5e6416831e2f5f9ef8b4b228200b5d17221b Mon Sep 17 00:00:00 2001 From: zman27 Date: Thu, 30 Nov 2023 14:05:39 -0500 Subject: [PATCH] first commit --- .gitignore | 2 + client/Dockerfile | 12 ++++ client/index.html | 10 ++++ docker-compose.yml | 20 +++++++ server/Dockerfile | 20 +++++++ server/db.sqlite3 | Bin 0 -> 131072 bytes server/manage.py | 22 +++++++ server/requirements.txt | 3 + server/server/__init__.py | 0 server/server/asgi.py | 16 +++++ server/server/settings.py | 123 ++++++++++++++++++++++++++++++++++++++ server/server/urls.py | 24 ++++++++ server/server/views.py | 5 ++ server/server/wsgi.py | 16 +++++ 14 files changed, 273 insertions(+) create mode 100644 .gitignore create mode 100644 client/Dockerfile create mode 100644 client/index.html create mode 100644 docker-compose.yml create mode 100644 server/Dockerfile create mode 100644 server/db.sqlite3 create mode 100755 server/manage.py create mode 100644 server/requirements.txt create mode 100644 server/server/__init__.py create mode 100644 server/server/asgi.py create mode 100644 server/server/settings.py create mode 100644 server/server/urls.py create mode 100644 server/server/views.py create mode 100644 server/server/wsgi.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..033df5f --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.venv +__pycache__ diff --git a/client/Dockerfile b/client/Dockerfile new file mode 100644 index 0000000..57a7dc5 --- /dev/null +++ b/client/Dockerfile @@ -0,0 +1,12 @@ +# Use an official nginx image +FROM nginx:alpine + +# Copy the static content into the Nginx server +COPY . /usr/share/nginx/html + +# Expose port 80 +EXPOSE 80 + +# Start Nginx and keep it running +CMD ["nginx", "-g", "daemon off;"] + diff --git a/client/index.html b/client/index.html new file mode 100644 index 0000000..8fb13e4 --- /dev/null +++ b/client/index.html @@ -0,0 +1,10 @@ + + + + Hello World Client + + +

Hello World from Client

+ + + diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..e3e7380 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,20 @@ +version: '3.9' + +services: + backend: + build: ./server + ports: + - "8000:8000" + volumes: + - ./server:/usr/src/app + environment: + - DEBUG=1 + command: python manage.py runserver 0.0.0.0:8000 + + frontend: + build: ./client + ports: + - "3000:80" + depends_on: + - backend + diff --git a/server/Dockerfile b/server/Dockerfile new file mode 100644 index 0000000..1ac0de1 --- /dev/null +++ b/server/Dockerfile @@ -0,0 +1,20 @@ +# Use an official Python runtime as a base image +FROM python:3.9 + +# Set environment variables +ENV PYTHONDONTWRITEBYTECODE 1 +ENV PYTHONUNBUFFERED 1 + +# Set the working directory in the container +WORKDIR /usr/src/app + +# Install any needed packages specified in requirements.txt +COPY requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt + +# Make port 8000 available to the world outside this container +EXPOSE 8000 + +# Run python manage.py runserver 0.0.0.0:8000 when the container launches +CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"] + diff --git a/server/db.sqlite3 b/server/db.sqlite3 new file mode 100644 index 0000000000000000000000000000000000000000..7cdfac302257ae2483ac8cc428926404c1e1a3bf GIT binary patch literal 131072 zcmeI5Yit}@R>!;C?QXa2?(!o}g`LT`+!@cL*YUWYwtI$U$CLCVW)f%OILugLR8)7D zoyzpX>2Bwtk$`qGvuGBOShOpF1cQ)}K=6U5Rn+fr~c=6Z{4ao_m+M2%0<1Y$y>F0MQzGy-RIhR-f^`Q2nDpW-NZ6*+}B|BPU0`JM!GfABH~+eJA{@ z!LJN%2Y$}~&4G^xE(@RYeXW*~rV+)>f}v%gd{4=kjmLF}KwLPGj=rweCVO z`E-m6(@U{4a*WF(J+XM}#qp4|ofBHB6@hVdN2^!#MnkVv8;Z5gf>_QJv&CFW zC(J19^1Fq?SJ??49aMt|M3_Q7olX*+Rl#Zt_I7fPuG1%LN(A97mM$`IU15yR)qU6 zHPu4dxK8=i&li@6hSj&Yk3`HMHdbD_n78*QZbOEZIuco@3fRH|5vzoAS!FjmxWRi;v7_r;((2mk z#_Gz&i<{=o{JE}1*sZC{yTzivbHw)&BOz&iUbsK$Ld&l(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$erzud$24ZvR7{k`r;(6<()tOHHZJgRZ(w^HAK6d2VP{2gT+;J*>{D-FhtV z?HN|~Gw|;Cfd-b%klEBBuURy$AC{MgUb!1;?w!ew00JNY0w4eaAOHd&00JNY z0wC}h5y1QZV^kTC0sI z_?O}ziyzPien0>OKmY_l00ck)1V8`;KmY_l00bTpfyrRNck(IoFR?Yuf1er*_-0R; zf0?6scSmd3)<**Y-_#WQGXd;R8btiGC9y63+x;g7Xmf^bT7QRNTnPB2ll;$^(4UOa zs?GXc_Wti1dqg3@EeL=B2!H?xfB*=900@8p2!H?xfWTuxz&8J1d@KY(1PFit2!H?x zfB*=900@8p2!H?xfWSj1V0-_6=)U0)1V8`;KmY_l00ck)1V8`;KmY_l;PD{ve^H8{ AZU6uP literal 0 HcmV?d00001 diff --git a/server/manage.py b/server/manage.py new file mode 100755 index 0000000..9856e02 --- /dev/null +++ b/server/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" +import os +import sys + + +def main(): + """Run administrative tasks.""" + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "server.settings") + try: + from django.core.management import execute_from_command_line + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc + execute_from_command_line(sys.argv) + + +if __name__ == "__main__": + main() diff --git a/server/requirements.txt b/server/requirements.txt new file mode 100644 index 0000000..a543531 --- /dev/null +++ b/server/requirements.txt @@ -0,0 +1,3 @@ +asgiref==3.7.2 +Django==4.2.7 +sqlparse==0.4.4 diff --git a/server/server/__init__.py b/server/server/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/server/server/asgi.py b/server/server/asgi.py new file mode 100644 index 0000000..2adb2d7 --- /dev/null +++ b/server/server/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for server project. + +It exposes the ASGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/4.2/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "server.settings") + +application = get_asgi_application() diff --git a/server/server/settings.py b/server/server/settings.py new file mode 100644 index 0000000..ea4b9f7 --- /dev/null +++ b/server/server/settings.py @@ -0,0 +1,123 @@ +""" +Django settings for server project. + +Generated by 'django-admin startproject' using Django 4.2.4. + +For more information on this file, see +https://docs.djangoproject.com/en/4.2/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/4.2/ref/settings/ +""" + +from pathlib import Path + +# Build paths inside the project like this: BASE_DIR / 'subdir'. +BASE_DIR = Path(__file__).resolve().parent.parent + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +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! +DEBUG = True + +ALLOWED_HOSTS = ['0.0.0.0' ,'localhost', '127.0.0.1'] + + +# Application definition + +INSTALLED_APPS = [ + "django.contrib.admin", + "django.contrib.auth", + "django.contrib.contenttypes", + "django.contrib.sessions", + "django.contrib.messages", + "django.contrib.staticfiles", +] + +MIDDLEWARE = [ + "django.middleware.security.SecurityMiddleware", + "django.contrib.sessions.middleware.SessionMiddleware", + "django.middleware.common.CommonMiddleware", + "django.middleware.csrf.CsrfViewMiddleware", + "django.contrib.auth.middleware.AuthenticationMiddleware", + "django.contrib.messages.middleware.MessageMiddleware", + "django.middleware.clickjacking.XFrameOptionsMiddleware", +] + +ROOT_URLCONF = "server.urls" + +TEMPLATES = [ + { + "BACKEND": "django.template.backends.django.DjangoTemplates", + "DIRS": [], + "APP_DIRS": True, + "OPTIONS": { + "context_processors": [ + "django.template.context_processors.debug", + "django.template.context_processors.request", + "django.contrib.auth.context_processors.auth", + "django.contrib.messages.context_processors.messages", + ], + }, + }, +] + +WSGI_APPLICATION = "server.wsgi.application" + + +# Database +# https://docs.djangoproject.com/en/4.2/ref/settings/#databases + +DATABASES = { + "default": { + "ENGINE": "django.db.backends.sqlite3", + "NAME": BASE_DIR / "db.sqlite3", + } +} + + +# Password validation +# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator", + }, + { + "NAME": "django.contrib.auth.password_validation.MinimumLengthValidator", + }, + { + "NAME": "django.contrib.auth.password_validation.CommonPasswordValidator", + }, + { + "NAME": "django.contrib.auth.password_validation.NumericPasswordValidator", + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/4.2/topics/i18n/ + +LANGUAGE_CODE = "en-us" + +TIME_ZONE = "UTC" + +USE_I18N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/4.2/howto/static-files/ + +STATIC_URL = "static/" + +# Default primary key field type +# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field + +DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" diff --git a/server/server/urls.py b/server/server/urls.py new file mode 100644 index 0000000..7070101 --- /dev/null +++ b/server/server/urls.py @@ -0,0 +1,24 @@ +""" +URL configuration for server project. + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/4.2/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: path('', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.urls import include, path + 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) +""" +from django.contrib import admin +from django.urls import path +from .views import hello_world + +urlpatterns = [ + path('', hello_world), + path("admin/", admin.site.urls), +] diff --git a/server/server/views.py b/server/server/views.py new file mode 100644 index 0000000..9dea469 --- /dev/null +++ b/server/server/views.py @@ -0,0 +1,5 @@ +from django.http import HttpResponse + +def hello_world(request): + return HttpResponse("Hello, World!") + diff --git a/server/server/wsgi.py b/server/server/wsgi.py new file mode 100644 index 0000000..649ca41 --- /dev/null +++ b/server/server/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for server project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/4.2/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "server.settings") + +application = get_wsgi_application()