From 25cc96b9867ecb448bd2c9bf3068f703fad81a0c Mon Sep 17 00:00:00 2001 From: Celestino Rey Date: Mon, 6 Jan 2025 20:51:08 +0100 Subject: [PATCH] Primer commit --- .s2i/environment | 7 ++ Procfile | 2 + manage.py | 22 ++++ myapp/__init__.py | 0 myapp/__pycache__/__init__.cpython-312.pyc | Bin 0 -> 156 bytes myapp/__pycache__/settings.cpython-312.pyc | Bin 0 -> 2598 bytes myapp/__pycache__/urls.cpython-312.pyc | Bin 0 -> 1021 bytes myapp/asgi.py | 16 +++ myapp/settings.py | 129 +++++++++++++++++++++ myapp/urls.py | 22 ++++ myapp/wsgi.py | 16 +++ requirements.txt | 4 + 12 files changed, 218 insertions(+) create mode 100644 .s2i/environment create mode 100644 Procfile create mode 100755 manage.py create mode 100644 myapp/__init__.py create mode 100644 myapp/__pycache__/__init__.cpython-312.pyc create mode 100644 myapp/__pycache__/settings.cpython-312.pyc create mode 100644 myapp/__pycache__/urls.cpython-312.pyc create mode 100644 myapp/asgi.py create mode 100644 myapp/settings.py create mode 100644 myapp/urls.py create mode 100644 myapp/wsgi.py create mode 100644 requirements.txt diff --git a/.s2i/environment b/.s2i/environment new file mode 100644 index 0000000..cb00d63 --- /dev/null +++ b/.s2i/environment @@ -0,0 +1,7 @@ +POSTGRESQL_DATABASE=mydb +POSTGRESQL_USER=myuser +POSTGRESQL_PASSWORD=mypassword +POSTGRESQL_HOST=postgresql +POSTGRESQL_PORT=5432 +DEBUG=False + diff --git a/Procfile b/Procfile new file mode 100644 index 0000000..31dfd03 --- /dev/null +++ b/Procfile @@ -0,0 +1,2 @@ +web: gunicorn myapp.wsgi --bind 0.0.0.0:$PORT + diff --git a/manage.py b/manage.py new file mode 100755 index 0000000..a53204a --- /dev/null +++ b/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', 'myapp.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/myapp/__init__.py b/myapp/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/myapp/__pycache__/__init__.cpython-312.pyc b/myapp/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..7700780ba79463c582ea0671d2933a687628383c GIT binary patch literal 156 zcmX@j%ge<81Yh=7rGx0lAOanHW&w&!XQ*V*Wb|9fP{ah}eFmxdWvw4toLW?@pPZVL zT3nKumtT}xsqbHqnirgrnO36jTj^L(pr2cr2q)v?GxIV_;^XxSDt~d<#Fv1ma>4<0CU8BV!RWkOcrD=qCmM literal 0 HcmV?d00001 diff --git a/myapp/__pycache__/settings.cpython-312.pyc b/myapp/__pycache__/settings.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..cedc5ce46773fad6139668f72284d679744d69bf GIT binary patch literal 2598 zcmb7G$#dFf6qf+AgE7HNmbUUF;{+!b<19_4OBxwuhY4E|#H|k12)@rCM+=rj9CYH| zOK-j8lv^kNMDM-C(?dKud8VgcIyjm3kW-%o#0>UKT?W4Gz4v?Xd)vovu~?XZ&&6M@ z)<02#_`}(ZKf%%B{a>*7nLq?jAQE|GQt|K}lJF4NgT1fGA=hqbEOs)#9xZoW9Vh3` z>Z~)~kGy;U`S@Uq;6p6}&AcM{FwB0KBPhT}5m1m1IkfOAQX*00rLRTuF%;$FD2C!_ z7A4ReN}>xW_0lhq{4APB3&1yz7Ts~l9WP2`%f~0sC4LTF=98fD0{l|w3O|oN;TL+J zrau!`;bP(3uBf&&%D|>6sV#%r(R51biJcDB(Y0ONH0f}73#(WcO^m2UkGhUri8T=^ zl1dq-sGB3s>r~eO3~B^>o;0*Oo05+($u>4d{b2duRbRgn;q@xG{I+P$Y__Gr$z zFf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JcQ@ENNR=7yKSX;Wx_trVqy0}RXHB*|# z3_8eg0Zlrik8>uTj``5ghqJvrr)BR~Ga?1~>|*s+CX;E(?x+pGvEkEOFr7AR+dgwP qZTAPU>}y}Ft7k2%dFkzycRTa&B%JS_?0$BypEjIL=gpeJH~9;F-ZVo1 literal 0 HcmV?d00001 diff --git a/myapp/asgi.py b/myapp/asgi.py new file mode 100644 index 0000000..5221a56 --- /dev/null +++ b/myapp/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for myapp 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/5.1/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myapp.settings') + +application = get_asgi_application() diff --git a/myapp/settings.py b/myapp/settings.py new file mode 100644 index 0000000..b6f0781 --- /dev/null +++ b/myapp/settings.py @@ -0,0 +1,129 @@ +""" +Django settings for myapp project. + +Generated by 'django-admin startproject' using Django 5.1.4. + +For more information on this file, see +https://docs.djangoproject.com/en/5.1/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/5.1/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/5.1/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'django-insecure-l3r@lmb$hl^2vbrs!zwu(7!8g)hx@g=&mqsuj+d(mqoeno_+&&' + +# SECURITY WARNING: don't run with debug turned on in production! + +# 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 = 'myapp.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 = 'myapp.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/5.1/ref/settings/#databases + +import os + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.postgresql', + 'NAME': os.getenv('POSTGRESQL_DATABASE', 'mydb'), + 'USER': os.getenv('POSTGRESQL_USER', 'myuser'), + 'PASSWORD': os.getenv('POSTGRESQL_PASSWORD', 'mypassword'), + 'HOST': os.getenv('POSTGRESQL_HOST', 'localhost'), + 'PORT': os.getenv('POSTGRESQL_PORT', '5432'), + } +} + +ALLOWED_HOSTS = ['*'] +DEBUG = os.getenv('DEBUG', 'False') == 'True' + + + +# Password validation +# https://docs.djangoproject.com/en/5.1/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/5.1/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/5.1/howto/static-files/ + +STATIC_URL = 'static/' + +# Default primary key field type +# https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field + +DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' diff --git a/myapp/urls.py b/myapp/urls.py new file mode 100644 index 0000000..c57fcb1 --- /dev/null +++ b/myapp/urls.py @@ -0,0 +1,22 @@ +""" +URL configuration for myapp project. + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/5.1/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 + +urlpatterns = [ + path('admin/', admin.site.urls), +] diff --git a/myapp/wsgi.py b/myapp/wsgi.py new file mode 100644 index 0000000..4b4a883 --- /dev/null +++ b/myapp/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for myapp 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/5.1/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myapp.settings') + +application = get_wsgi_application() diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..cbb9bf8 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,4 @@ +asgiref==3.8.1 +Django==5.1.4 +psycopg2-binary==2.9.10 +sqlparse==0.5.3