34 Commits
Author SHA1 Message Date
Pierre Geeraert 80a75a445e working on views
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 35s
2025-05-30 11:51:23 +01:00
pi-ux-ce 385d42d0be update secret
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 43s
2025-04-16 11:13:00 +01:00
pi-ux-ce 2514603962 Display the URL instead of redirection
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 2m34s
2025-03-10 08:28:59 +00:00
pi-ux-ce d071b135e7 use Infrequent_access instead
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 2m8s
2024-11-12 11:08:05 +00:00
pi-ux-ce 433185df3e enable .gitignore
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 37s
2024-11-12 11:03:56 +00:00
pi-ux-ce ccad16f38c change to an URL instead
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 41s
2024-11-12 11:02:28 +00:00
pi-ux-ce c7e5afc750 add scale down as well and remove debug
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 55s
2024-11-06 22:44:47 +00:00
pi-ux-ce 80877663a9 new version with the scale Up option
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 59s
2024-11-06 11:09:52 +00:00
pi-ux-ce ceaf0f0ef6 separate the runners
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 7s
2024-10-30 11:15:46 +00:00
pi-ux-ce d6135402c2 separate the runners
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 7s
2024-10-30 11:15:31 +00:00
pi-ux-ce fa365f956e optimise by running a pip upgrade
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 3m56s
2024-10-30 11:11:11 +00:00
pi-ux-ce 82ed5d12e1 it was working actually
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 3m20s
2024-10-30 11:07:43 +00:00
pi-ux-ce a9b6c92864 try againto apply migrations
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 2m42s
2024-10-30 11:02:10 +00:00
pi-ux-ce cc2d9e1b14 try to apply migrations
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 2m55s
2024-10-30 10:54:26 +00:00
pi-ux-ce 3dd8fdb7ca try to apply migrations
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 2m47s
2024-10-30 10:47:00 +00:00
pi-ux-ce db20b291e3 modify other file to test action trigger 2024-10-29 23:27:32 +00:00
pi-ux-ce 096a71a7fc remove pyyaml just to trigger action
Gitea Actions Demo / Explore-Gitea-Actions (push) Has been cancelled
2024-10-29 23:26:53 +00:00
pi-ux-ce 83d346b632 update dockerfile only to test the action trigger 2024-10-29 23:26:22 +00:00
pi-ux-ce 202797aed5 install pyyaml just to trigger action 2024-10-29 23:25:04 +00:00
pi-ux-ce 0cb583de09 update dockerfile only to test the action trigger 2024-10-29 23:23:55 +00:00
pi-ux-ce bf19250116 update dockerfile only to test the action trigger 2024-10-29 23:23:06 +00:00
pi-ux-ce e59e7b439d try this new action 2024-10-29 23:22:24 +00:00
pi-ux-ce 83e2ba5be2 update code with latest version
Gitea Actions Demo / Explore-Gitea-Actions (push) Has been cancelled
2024-10-29 23:17:04 +00:00
pi-ux-ce 7cc8891533 needs this secret 2024-10-29 23:16:10 +00:00
pi-ux-ce 8a0cd24d69 also upload new yaml file to check differences 2024-10-29 23:15:57 +00:00
pi-ux-ce 1cb49c3127 add django_code_new just in case before removing it 2024-10-29 23:15:37 +00:00
pi-ux-ce a4a704305a try pyyaml
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 3m12s
2024-10-29 22:57:31 +00:00
pi-ux-ce f21877877b try this to import yaml files
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 3m38s
2024-10-29 22:41:23 +00:00
pi-ux-ce ff48f982f5 add kubernetes dependencies
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 3m44s
2024-10-29 17:10:46 +00:00
pi-ux-ce f661ac26c8 add build image process
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 5m54s
2024-10-23 15:17:34 +01:00
pi-ux-ce 1100043b2f try this runner here
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 11s
2024-10-23 10:54:12 +01:00
pi-ux-ce 1d031088a9 add changes 2024-10-22 12:44:31 +01:00
pi-ux-ce 056104a553 update code 2024-10-22 12:42:28 +01:00
pi-ux-ce 87185595e2 ✨ add CPU and MEMORY limit 2024-07-24 15:37:08 +01:00
131 changed files with 516701 additions and 1074 deletions
+40
View File
@@ -0,0 +1,40 @@
name: Gitea Actions Demo
run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀
on:
push:
branches:
- "*"
paths:
- 'dockerfile'
tags-ignore:
- '*'
jobs:
Explore-Gitea-Actions:
runs-on: ubuntu-latest
steps:
- run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
- name: Check out repository code
uses: actions/checkout@v4
- run: echo "💡 The ${{ gitea.repository }} repository has been cloned to the runner."
- name: List files in the repository
run: |
ls ${{ gitea.workspace }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to gitea
uses: docker/login-action@v3
with:
registry: gitea.tryton.geeraert.eu
username: ${{ secrets.USERNAME_GITEA }}
password: ${{ secrets.PASSWORD_GITEA }}
- name: Build and push
uses: docker/build-push-action@v6
with:
push: true
tags: gitea.tryton.geeraert.eu/pi-ux-ce/django-python:latest
- run: echo "🍏 This job's status is ${{ job.status }}."
+23
View File
@@ -0,0 +1,23 @@
name: Gitea Actions Demo
run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀
on: [push]
jobs:
Explore-Gitea-Actions:
runs-on: ubuntu-latest
steps:
- run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
- name: Check out repository code
uses: actions/checkout@v4
- run: echo "💡 The ${{ gitea.repository }} repository has been cloned to the runner."
- name: List files in the repository
run: |
ls ${{ gitea.workspace }}
- name: Perform kubectl tasks
uses: actions-hub/kubectl@master
env:
KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }}
with:
args: apply -f .
- run: echo "🍏 This job's status is ${{ job.status }}."
+1
View File
@@ -0,0 +1 @@
*/__pycache__/*
+10 -2
View File
@@ -20,7 +20,7 @@ spec:
spec: spec:
containers: containers:
- name: django-python - name: django-python
image: localhost:31795/django-python image: gitea.tryton.geeraert.eu/pi-ux-ce/django-python:latest
imagePullPolicy: Always imagePullPolicy: Always
ports: ports:
- containerPort: 8000 - containerPort: 8000
@@ -28,14 +28,22 @@ spec:
volumeMounts: volumeMounts:
- name: django-python-code - name: django-python-code
mountPath: /code mountPath: /code
- name: servarr-data
mountPath: /data
readOnly: true
resources: resources:
limits: limits:
cpu: 100m cpu: 100m
memory: 50Mi memory: 200Mi
volumes: volumes:
- name: django-python-code - name: django-python-code
persistentVolumeClaim: persistentVolumeClaim:
claimName: django-python-code claimName: django-python-code
- name: servarr-data
hostPath:
path: /data
--- ---
apiVersion: v1 apiVersion: v1
+1 -1
View File
@@ -1,6 +1,6 @@
======= =======
# Django_kube # Django_kube
test
## Getting started ## Getting started
+10
View File
@@ -0,0 +1,10 @@
from django.apps import AppConfig
from django.http import HttpResponse
from django.shortcuts import render
from django.shortcuts import redirect
import time
import random
def hello(request):
return HttpResponse('<h1>Hello dashboard h1>')
@@ -0,0 +1,32 @@
<!DOCTYPE html>
<html>
<head>
<title>{% block title %}{% endblock %}</title>
{% load bootstrap5 %}
{% bootstrap_css %}
{% bootstrap_javascript %}
</head>
<body>
<h1 class="display-1">Welcome to my website!</h1>
<div class="container">
<div class="list-group">
{% if thislist %}
<ul>
{% for question in thislist %}
<a href="#" class="list-group-item">{{ question }}</a>
{% endfor %}
</ul>
{% else %}
<p>No polls are available.</p>
{% endif %}
</div>
</div>
{% block content %}
{% endblock %}
</div>
</body>
</html>
+18
View File
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html>
<head>
<title>My Website</title>
</head>
<body>
<h1>Welcome to my website!</h1>
{% if thislist %}
<ul>
{% for question in thislist %}
<h1>{{ question }}</h1>
{% endfor %}
</ul>
{% else %}
<p>No polls are available.</p>
{% endif %}
</body>
</html>
+9
View File
@@ -0,0 +1,9 @@
from django.shortcuts import render
def home(request):
thislist = ["apple", "banana", "cherry"]
return render(request, 'home.html',{'thislist': thislist})
def about(request):
thislist = ["apple", "banana", "cherry"]
return render(request, 'about.html',{'thislist': thislist})
+5 -2
View File
@@ -25,7 +25,7 @@ SECRET_KEY = 'django-insecure-71%)_#e#o9-dl2o^6mfud-*rw+4+8vy-nd*bzeier&(34ap-p9
# 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
ALLOWED_HOSTS = ['reverse.tryton.geeraert.eu','192.168.4.100','django.tryton.geeraert.eu'] ALLOWED_HOSTS = ['reverse.tryton.geeraert.eu','192.168.4.100','django.tryton.geeraert.eu','localhost']
# Application definition # Application definition
@@ -37,6 +37,7 @@ INSTALLED_APPS = [
'django.contrib.sessions', 'django.contrib.sessions',
'django.contrib.messages', 'django.contrib.messages',
'django.contrib.staticfiles', 'django.contrib.staticfiles',
'bootstrap5',
] ]
MIDDLEWARE = [ MIDDLEWARE = [
@@ -54,7 +55,8 @@ ROOT_URLCONF = 'django_code.urls'
TEMPLATES = [ TEMPLATES = [
{ {
'BACKEND': 'django.template.backends.django.DjangoTemplates', 'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [], #'DIRS': ["/code/django_code/templates","/code/django_code/dashboard/templates/"],
'DIRS': [BASE_DIR / "templates","django_code/dashboard/templates/"],
'APP_DIRS': True, 'APP_DIRS': True,
'OPTIONS': { 'OPTIONS': {
'context_processors': [ 'context_processors': [
@@ -121,3 +123,4 @@ STATIC_URL = 'static/'
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field # https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
#
+35 -6
View File
@@ -18,16 +18,45 @@ from django.contrib import admin
from django.urls import path from django.urls import path
#from docker_connection import views, apps #from docker_connection import views, apps
from random_simpsons import apps as random_simpsons from random_simpsons import apps as random_simpsons
from paperless_django import apps as paperless_django
from onenote import apps as onenote
from dashboard import apps as dashboardapp
from dashboard import views as dashboardview
from kubernetes_connection import apps as kubernetes_connection
urlpatterns = [ urlpatterns = [
# path('admin/', admin.site.urls), # path('admin/', admin.site.urls),
path('hello/', random_simpsons.hello),
# path('bookstack/', docker_connection.apps.hello),
# path('test/', docker_connection.apps.http_call_test),
# path('proxmox/', docker_connection.apps.proxmox),
# path('simpsons/', random_simpsons.hello),
path('simpsons/', random_simpsons.simpsons),
################### Simpsons ###################
path('hello/', random_simpsons.hello),
path('simpsons/', random_simpsons.simpsons),
path('download_file/', random_simpsons.download_file),
################### paperless ###################
path('paperless/hello/', paperless_django.hello),
# path('simpsons/', random_simpsons.simpsons),
################### onenote ###################
path('onenote/hello/', onenote.hello),
################### onenote ###################
path('dashboard/hello/', dashboardapp.hello),
path('dashboard/view/about', dashboardview.about),
path('dashboard/view/home', dashboardview.home),
################## kubernetes_connection#####
path('kubernetes_connection/hello/', kubernetes_connection.hello),
path('kubernetes_connection/nodes/', kubernetes_connection.nodes),
path('kubernetes_connection/backup_job/', kubernetes_connection.backup_job),
path('kubernetes_connection/backup_job_yaml/', kubernetes_connection.backup_job_yaml),
path('kubernetes_connection/scale_up/<str:namespace_name>/<str:deploy_name>', kubernetes_connection.scale_up),
path('kubernetes_connection/scale_down/<str:namespace_name>/<str:deploy_name>', kubernetes_connection.scale_down),
# path('bookstack/', docker_connection.apps.hello),
# path('test/', docker_connection.apps.http_call_test),
# path('proxmox/', docker_connection.apps.proxmox),
# path('simpsons/', random_simpsons.hello),
# path('docker/<str:action>/<str:id_docker>', docker_connection.apps.docker_call), # path('docker/<str:action>/<str:id_docker>', docker_connection.apps.docker_call),
+125
View File
@@ -0,0 +1,125 @@
from django.apps import AppConfig
from django.http import HttpResponse
from django.shortcuts import render
from django.shortcuts import redirect
from django.core.files import File
from kubernetes import client, config
#from django.template.loader import render_to_string
import time
import random
import mimetypes
import ruamel.yaml
import yaml
import urllib.request
def hello(request):
return HttpResponse('<h1>Hello k8s!</h1>')
def scale_up(request,namespace_name,deploy_name):
config.load_kube_config(config_file='/code/kubeconfig')
api = client.AppsV1Api()
deployment = api.read_namespaced_deployment(name=deploy_name, namespace=namespace_name)
deployment.spec.replicas = 2
resp = api.patch_namespaced_deployment(
name=deploy_name, namespace=namespace_name, body=deployment);
return HttpResponse('<h1>Scaled up !</h1>')
def scale_down(request,namespace_name,deploy_name):
config.load_kube_config(config_file='/code/kubeconfig')
api = client.AppsV1Api()
deployment = api.read_namespaced_deployment(name=deploy_name, namespace=namespace_name)
deployment.spec.replicas = 0
resp = api.patch_namespaced_deployment(
name=deploy_name, namespace=namespace_name, body=deployment);
return HttpResponse('<h1>Scaled down !</h1>')
def nodes(request):
config.load_kube_config(config_file='/code/kubeconfig')
v1 = client.CoreV1Api()
# v1.list_node()
pod_manifest = {
'apiVersion': 'v1',
'kind': 'Pod',
'metadata': {
'labels': {
'bot': 'current-bot'
},
'name': 'podname',
'namespace': 'echo-server'
},
'spec': {
'containers': [{
'image': 'gitea.tryton.geeraert.eu/pi-ux-ce/bitwarden_cli:1.0.1',
# 'pod-running-timeout': '5m0s',
'name': 'testpython',
'env': [
{'name': 'env_variable', 'value': 'env_value'},
]
}],
'restartPolicy': 'Always',
# 'serviceAccountName': 'bots-service-account'
}
}
# print(f'POD MANIFEST:\n{pod_manifest}')
api_response = v1.create_namespaced_pod(body=pod_manifest,namespace='echo-server')
return HttpResponse(api_response)
def backup_job(request):
config.load_kube_config(config_file='/code/kubeconfig')
v1 = client.CoreV1Api()
#v1 = client.BatchV1Api()
# v1.list_node()
pod_manifest_job = {
'apiVersion': 'batch/v1',
'kind': 'Job',
'metadata': {
'name': 'bitwarden-backup-django',
'namespace': 'bwbackup'
},
'spec': {
'template': {
'spec': {
'containers': [{
'image': 'gitea.tryton.geeraert.eu/pi-ux-ce/bitwarden_cli:1.0.1',
'name': 'testpython',
'command': ['/bin/sh -c /config/export_bitwarden.sh'],
'env': [
{'name': 'env_variable', 'value': 'env_value'},
],
'volumeMounts': [
{'name': 'scripts', 'configMap': [{'name':'bitwarden-export-scripts'},]},
]
}],
'restartPolicy': 'Always',
}
}
}
}
api_response = v1.create_namespaced_job(body=pod_manifest_job)
return HttpResponse(api_response)
#help with yaml import
#https://github.com/kubernetes-client/python/issues/589
def backup_job_yaml(request):
config.load_kube_config(config_file='/code/kubeconfig')
v1 = client.BatchV1Api()
with urllib.request.urlopen(https://gitea.tryton.geeraert.eu/pi-ux-ce/Backup_kube/raw/branch/main/Infrequent_access/pod.yaml") as manifest_url:
# with open('/code/pod.yaml') as :
job = yaml.safe_load(manifest_url)
v1.create_namespaced_job(
job['metadata']['namespace'], job, pretty=True
)
return HttpResponse(job['metadata']['namespace'])
@@ -0,0 +1 @@
<h1>Hello template!</h1>
Binary file not shown.
Binary file not shown.
+27
View File
@@ -0,0 +1,27 @@
from django.apps import AppConfig
from django.http import HttpResponse
from django.shortcuts import render
from django.shortcuts import redirect
#from django.template.loader import render_to_string
from django.template import loader
#import time
#import random
def hello(request):
# htmlContent = '
#<!DOCTYPE html>
#<html lang="en">
#<body>
#<strong>Hello World from const</strong>
#</body>
#</html>
#'
# response = "coucou"
# context = {'response': HttpResponse(response)}
# return HttpResponse(htmlContent)
# return HttpResponse('<h1>Hello onenote! <h1>')
# return render(request, 'hello.html', context)
template = loader.get_template('onenote/hello.html')
# template = loader.get_template('onenote/Roser.mht')
return HttpResponse(template.render())
+6
View File
@@ -0,0 +1,6 @@
<!DOCTYPE html>
<html lang="en">
<body>
<strong>Hello World</strong>
</body>
</html>
+16
View File
@@ -0,0 +1,16 @@
from django.apps import AppConfig
from django.http import HttpResponse
from django.shortcuts import render
from django.shortcuts import redirect
import time
import random
def hello(request):
return HttpResponse('<h1>Hello paperless! <h1>')
def redirect_authenticated(request):
final_url = "https://paperless.tryton.geeraert.eu/"
print(final_url)
return redirect(str(final_url))
+37 -3
View File
@@ -2,14 +2,48 @@ from django.apps import AppConfig
from django.http import HttpResponse from django.http import HttpResponse
from django.shortcuts import render from django.shortcuts import render
from django.shortcuts import redirect from django.shortcuts import redirect
from django.core.files import File
#from django.template.loader import render_to_string
import time import time
import random import random
import mimetypes
def hello(request): def hello(request):
return HttpResponse('<h1>Hello Simpsons!</h1>') return HttpResponse('<h1>Hello Simpsons!</h1>')
#<h1>href="{{ STATIC_URL }}/files/somefile</h1>)
def download_file(request):
# fill these variables with real values
fl_path = '/data/download/sonarr'
filename = 'The.Boys.2019.S04E05.2160p.HDR10Plus.WEBRip.6CH.x265.HEVC-PSA.mkv'
# fl = open(fl_path, 'r')
# mime_type, _ = mimetypes.guess_type(fl_path)
# response = HttpResponse(fl, content_type=mime_type)
# response['Content-Disposition'] = "attachment; filename=%s" % filename
some_file = open('/data/kubernetes/Backup/nextcloud/notes/2024-07-28/Course.md', "r")
django_file = File(some_file)
return HttpResponse("<h1>Hello download!</h1><h1><a href='{{ MEDIA_URL }}{{ django_file.relative_path }}'>{{ django_file.name }}</a></h1><h1>bye download!</h1>")
# return response
def download_mo(request,file):
path_to_file = os.path.realpath(file)
response = FileResponse(open(path_to_file, 'rb'))
file_name = file[5:]
response['Content-Disposition'] = 'inline; filename=' + file_name
return response
#def template(request):
# rendered = render_to_string("my_template.html", {"foo": "bar"})
#return HttpResponse('<h1>Hello !</h1>')
def simpsons(request): def simpsons(request):
simpsons_url = "https://www1.kisscartoon.online/episode/the-simpsons-season-"; # simpsons_url = "https://www1.kisscartoon.online/episode/the-simpsons-season-";
simpsons_url = "https://kisscartoon.top/episode/the-simpsons-season-";
number_of_seasons = 35 number_of_seasons = 35
seasons_maximum_number = [13,22,24,22,22,25,25,25,25,23,22,21,22,22,22,21,22,22,20,21,23,22,22,22,22,22,22,22,21,23,22,22,22,22,18] seasons_maximum_number = [13,22,24,22,22,25,25,25,25,23,22,21,22,22,22,21,22,22,20,21,23,22,22,22,22,22,22,22,21,23,22,22,22,22,18]
@@ -29,6 +63,6 @@ def simpsons(request):
final_url = simpsons_url+str(random_seasons)+ "-episode-"+str(random_episode)# final_url = simpsons_url+str(random_seasons)+ "-episode-"+str(random_episode)#
print(final_url) print(final_url)
# return HttpResponse(str(final_url)) return HttpResponse(str(final_url))
# time.sleep(10) # time.sleep(10)
return redirect(str(final_url)) # return redirect(str(final_url))
@@ -0,0 +1 @@
<h1>Hello template!</h1>
File diff suppressed because it is too large Load Diff
+6
View File
@@ -0,0 +1,6 @@
<!DOCTYPE html>
<html lang="en">
<body>
<strong>Hello World template</strong>
</body>
</html>
+2
View File
@@ -5,7 +5,9 @@ WORKDIR /code/
COPY requirements.txt ./ COPY requirements.txt ./
COPY django_code ./ COPY django_code ./
RUN pip install --upgrade pip
RUN pip install --no-cache-dir -r requirements.txt RUN pip install --no-cache-dir -r requirements.txt
COPY . . COPY . .
RUN python django_code/manage.py migrate
CMD [ "python","django_code/manage.py","runserver","0.0.0.0:8000" ] CMD [ "python","django_code/manage.py","runserver","0.0.0.0:8000" ]
File diff suppressed because one or more lines are too long
@@ -1,16 +0,0 @@
"""
ASGI config for Django_reverse_proxy 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', 'Django_reverse_proxy.settings')
application = get_asgi_application()
@@ -1,123 +0,0 @@
"""
Django settings for Django_reverse_proxy project.
Generated by 'django-admin startproject' using Django 4.2.5.
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-cdzm0zn@rzk#ix9mj9q3-ov%r^)-$u#met(_48s(x2we41+0!o'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# 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 = 'Django_reverse_proxy.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 = 'Django_reverse_proxy.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'
@@ -1,24 +0,0 @@
"""
URL configuration for Django_reverse_proxy 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 .. import frontend
urlpatterns = [
path('admin/', admin.site.urls),
# path('/', frontend.site.urls),
]
@@ -1,16 +0,0 @@
"""
WSGI config for Django_reverse_proxy 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', 'Django_reverse_proxy.settings')
application = get_wsgi_application()
Binary file not shown.
@@ -1,6 +0,0 @@
from django.apps import AppConfig
class FrontendConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'frontend'
@@ -1,3 +0,0 @@
from django.shortcuts import render
# Create your views here.
-22
View File
@@ -1,22 +0,0 @@
#!/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', 'Django_reverse_proxy.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()
-3
View File
@@ -1,3 +0,0 @@
from django.contrib import admin
# Register your models here.
-40
View File
@@ -1,40 +0,0 @@
from django.apps import AppConfig
from django.http import HttpResponse
from django.shortcuts import render
import requests
from proxmoxer import ProxmoxAPI
import docker
class BackofficeConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'backoffice'
def hello(request):
return HttpResponse('<h1>Start bookstack!</h1>')
def http_call_test(request):
url = 'http://portainer.zeus.geeraert.eu/api/auth/'
myobj = {'Username': 'admin','Password':'Xtm78*CX3mJ54g'}
x = requests.post(url, json = myobj)
print(x.text)
return HttpResponse(x.text)
def proxmox(request):
proxmox = ProxmoxAPI("proxmox.zeus.geeraert.eu", user="root@pam", password="dinner_sl@v3", verify_ssl=False)
return HttpResponse(proxmox)
def docker_call(request,action,id_docker):
print(action)
print(id_docker)
client = docker.from_env()
if action == "start":
print("nous allons start")
client.containers.get(id_docker).start()
if action == "stop":
print("nous allons stop")
client.containers.get(id_docker).stop()
return HttpResponse(client.containers.get(id_docker).status)
-3
View File
@@ -1,3 +0,0 @@
from django.db import models
# Create your models here.
-3
View File
@@ -1,3 +0,0 @@
from django.test import TestCase
# Create your tests here.
View File
View File
-16
View File
@@ -1,16 +0,0 @@
"""
ASGI config for eboutique 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', 'eboutique.settings')
application = get_asgi_application()
-124
View File
@@ -1,124 +0,0 @@
"""
Django settings for eboutique project.
Generated by 'django-admin startproject' using Django 4.2.5.
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-g--8(!mq=_qs3)iipm%vs8bu0j8upir2i*&*gw&0)v26%lq=2!'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'backoffice',
]
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 = 'eboutique.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 = 'eboutique.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'
-30
View File
@@ -1,30 +0,0 @@
"""
URL configuration for Django_reverse_proxy 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 backoffice import views, apps
urlpatterns = [
path('admin/', admin.site.urls),
path('hello/', views.hello),
path('bookstack/', apps.hello),
path('test/', apps.http_call_test),
path('proxmox/', apps.proxmox),
path('docker/<str:action>/<str:id_docker>', apps.docker_call),
]
-16
View File
@@ -1,16 +0,0 @@
"""
WSGI config for eboutique 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', 'eboutique.settings')
application = get_wsgi_application()
-22
View File
@@ -1,22 +0,0 @@
#!/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', 'eboutique.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()
+3
View File
@@ -2,3 +2,6 @@ django
requests requests
proxmoxer proxmoxer
docker docker
kubernetes
ruamel.yaml
pyyaml
-3
View File
@@ -1,3 +0,0 @@
from django.contrib import admin
# Register your models here.
-46
View File
@@ -1,46 +0,0 @@
from django.apps import AppConfig
from django.http import HttpResponse
from django.shortcuts import render
import requests
from proxmoxer import ProxmoxAPI
import docker
class BackofficeConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'backoffice'
def hello(request):
return HttpResponse('<h1>Start bookstack!</h1>')
def http_call_test(request):
url = 'http://portainer.zeus.geeraert.eu/api/auth/'
myobj = {'Username': 'admin','Password':'Xtm78*CX3mJ54g'}
x = requests.post(url, json = myobj)
print(x.text)
return HttpResponse(x.text)
def proxmox(request):
proxmox = ProxmoxAPI("proxmox.zeus.geeraert.eu", user="root@pam", password="dinner_sl@v3", verify_ssl=False)
return HttpResponse(proxmox)
def docker_call(request,action,id_docker):
print(action)
print(id_docker)
client = docker.from_env()
if action == "start":
print("nous allons start")
client.containers.get(id_docker).start()
if action == "stop":
print("nous allons stop")
client.containers.get(id_docker).stop()
return HttpResponse(client.containers.get(id_docker).status)
@@ -1,3 +0,0 @@
from django.db import models
# Create your models here.
-3
View File
@@ -1,3 +0,0 @@
from django.test import TestCase
# Create your tests here.
-8
View File
@@ -1,8 +0,0 @@
from django.shortcuts import render
# Create your views here.
from django.http import HttpResponse
from django.shortcuts import render
def hello(request):
return HttpResponse('<h1>Hello Django!</h1>')
-22
View File
@@ -1,22 +0,0 @@
#!/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', 'reverse_proxy.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()
-16
View File
@@ -1,16 +0,0 @@
"""
ASGI config for reverse_proxy 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', 'reverse_proxy.settings')
application = get_asgi_application()

Some files were not shown because too many files have changed in this diff Show More