Merge branch 'revert-d71c9505' into 'main'

Revert "💥 add all the files"

See merge request pierre/nextcloud_ics_sync!1
This commit was merged in pull request #1.
This commit is contained in:
2024-07-23 15:30:22 +00:00
101 changed files with 153 additions and 1158 deletions
-49
View File
@@ -1,49 +0,0 @@
apiVersion: v1
kind: Namespace
metadata:
name: django-python
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: django-webserver
namespace: django-python
spec:
replicas: 1
selector:
matchLabels:
app: django-python
template:
metadata:
labels:
app: django-python
spec:
containers:
- name: django-python
image: localhost:31795/django-python
imagePullPolicy: Always
ports:
- containerPort: 8000
name: webserver-port
volumeMounts:
- name: django-python-code
mountPath: /code
volumes:
- name: django-python-code
persistentVolumeClaim:
claimName: django-python-code
---
apiVersion: v1
kind: Service
metadata:
name: webserver
namespace: django-python
spec:
ports:
- name: http
port: 8000
protocol: TCP
selector:
app: django-python
+13
View File
@@ -0,0 +1,13 @@
FROM python:3
WORKDIR /usr/src/app
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
#RUN echo "nameserver 8.8.8.8" >> /etc/resolv.conf
#CMD [ "python", "./nextcloud_ics_sync.py",">>","/var/log/nextcloud-ics-sync.log"]
#CMD [ "sleep","3600" ]
CMD echo "==================================================================================" >> /var/log/nextcloud-ics-sync.log 2>&1 ; echo $(date) >> /var/log/nextcloud-ics-sync.log 2>&1 ; python ./nextcloud_ics_sync.py >> /var/log/nextcloud-ics-sync.log 2>&1 ; echo "==================================================================================" >> /var/log/nextcloud-ics-sync.log 2>&1
+1 -1
View File
@@ -1 +1 @@
copy reverse-proxy folder to PVC
sudo docker build -t nextcloud_ics_sync .
-11
View File
@@ -1,11 +0,0 @@
FROM python:3
WORKDIR /code/
COPY requirements.txt ./
COPY reverse_proxy ./
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
CMD [ "python","reverse_proxy/manage.py","runserver","0.0.0.0:8000" ]
-4
View File
@@ -1,4 +0,0 @@
apiVersion: v1
kind: Namespace
metadata:
name: django-python
+10
View File
@@ -0,0 +1,10 @@
[DEFAULT]
username: calendar_sync
password: Displace6ArmingHeadroom
server: https://nextcloud.tryton.geeraert.eu/
[sam-pierre]
calendar: shared
ics_url: https://outlook.live.com/owa/calendar/90488edb-6373-4e0f-bde7-4b04b9385f5a/6982a203-79f2-419a-ac81-4164ce572d99/cid-B2051C269DBC4793/calendar.ics
ics_username :
ics_password :
+86
View File
@@ -0,0 +1,86 @@
#!/usr/bin/env python3
import configparser, logging, requests, traceback
from icalendar.cal import Calendar
log_option = {
'format': '[%(asctime)s] [%(levelname)s] %(message)s',
'level': getattr(logging, 'INFO')
}
logging.basicConfig(**log_option)
logging.getLogger("requests").setLevel(logging.WARNING)
CALDAVURL = '%sremote.php/dav/calendars/%s/%s'
def do_import(username, password, calendar, server, ics_url, ics_username, ics_password):
logging.info(' Working with calendar %s...' % calendar)
base_url = CALDAVURL % (server, username, calendar)
target_fetch_url = '%s?export' % base_url
r = requests.get(target_fetch_url, auth=(username, password))
r.raise_for_status()
try:
target_cal = Calendar.from_ical(r.text)
except ValueError as e:
logging.error(' Warning: Could not parse iCal (%s)' % target_fetch_url)
logging.error(e)
return
existing_uids = [bytes.decode(e['UID'].to_ical()).replace('\'', '').replace('/', 'slash') for e in target_cal.walk('VEVENT')]
sourceRequest = requests.get(ics_url, auth=(ics_username, ics_password))
sourceRequest.encoding = 'utf-8'
sourceContent = sourceRequest.text
c = Calendar.from_ical(sourceContent)
distant_uids = [bytes.decode(e['UID'].to_ical()).replace('\'', '').replace('/', 'slash') for e in c.walk('VEVENT')]
imported_uids = []
for e in c.walk('VEVENT'):
uid = bytes.decode(e['UID'].to_ical()).replace('\'', '').replace('/', 'slash')
name = bytes.decode(e['SUMMARY'].to_ical())
if uid not in existing_uids:
cal = Calendar()
cal.add_component(e)
r = requests.put('%s/%s.ics' % (base_url, uid),
data=cal.to_ical(),
auth=(username, password),
headers={'content-type': 'text/calendar; charset=UTF-8'}
)
if r.status_code == 500 and r'Sabre\VObject\Recur\NoInstancesException' in r.text:
logging.warning(' No valid instances: %s (%s)' % (uid, name))
elif r.status_code == 201 or r.status_code == 204:
logging.info(' Imported: %s (%s)' % (uid, name))
imported_uids.append(uid)
else:
r.raise_for_status()
for euid in existing_uids:
if not euid in distant_uids:
r = requests.delete('%s/%s.ics' % (base_url, euid), auth=(username, password))
if r.status_code == 204:
logging.info('Deleted %s' % euid)
elif r.status_code == 404:
pass
else:
r.raise_for_status()
logging.info(' Done.')
if __name__ == '__main__':
logging.info('Initializing script...')
Config = configparser.RawConfigParser()
Config.read('nextcloud_ics_sync.ini')
logging.info('Done.')
logging.info('Importing calendars...')
for key in Config.sections():
logging.info(' Working on section %s' % key)
try:
do_import(
Config.get(key, 'username'), Config.get(key, 'password'), Config.get(key, 'calendar'), Config.get(key, 'server'),
Config.get(key, 'ics_url'), Config.get(key, 'ics_username'), Config.get(key, 'ics_password')
)
except Exception as e:
logging.error(traceback.print_exc())
logging.info(' Done.')
logging.info('Done.')
+35
View File
@@ -0,0 +1,35 @@
apiVersion: v1
kind: Namespace
metadata:
name: nextcloud-ics-sync
---
apiVersion: batch/v1
kind: CronJob
metadata:
name: nextcloud-ics-sync
namespace: nextcloud-ics-sync
spec:
schedule: "31 * * * *"
jobTemplate:
spec:
ttlSecondsAfterFinished: 100
template:
spec:
# nodeName: kube-master
containers:
- name: nextcloud-ics-sync
# image: nextcloud_ics_sync
image: localhost:31795/nextcloud_ics_sync
# imagePullPolicy: Never
volumeMounts:
- name: nextcloud-ics-sync-log
mountPath: /var/log/nextcloud-ics-sync.log
restartPolicy: Never
dnsConfig:
nameservers:
- 8.8.8.8
volumes:
- name: nextcloud-ics-sync-log
hostPath:
path: /var/log/nextcloud-ics-sync.log
type: File
@@ -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,3 +0,0 @@
from django.contrib import admin
# Register your models here.
@@ -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.db import models
# Create your models here.
@@ -1,3 +0,0 @@
from django.test import TestCase
# Create your tests here.
@@ -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.
-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>')
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()
-12
View File
@@ -1,12 +0,0 @@
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: django-python-code
namespace: django-python
spec:
storageClassName: nfs-storage-intelligent
accessModes:
- ReadWriteMany
resources:
requests:
storage: 2Gi
+2 -4
View File
@@ -1,4 +1,2 @@
django
requests
proxmoxer
docker
requests>=2.20.0
icalendar==3.9.2
-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()
@@ -1,3 +0,0 @@
from django.contrib import admin
# Register your models here.
@@ -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.
@@ -1,3 +0,0 @@
from django.test import TestCase
# Create your tests here.
@@ -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()
@@ -1,3 +0,0 @@
from django.contrib import admin
# Register your models here.
@@ -1,34 +0,0 @@
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 Simpsons!</h1>')
def simpsons(request):
simpsons_url = "https://www1.kisscartoon.online/episode/the-simpsons-season-";
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]
#print(simpsons_url)
random_seasons = random.randint(1, number_of_seasons)
print("random seasons: "+ str(random_seasons))
#random_seasons-1 because list start at index 0
print("maximum of episode for this season: "+str(seasons_maximum_number[random_seasons-1]))
random_episode = random.randint(1, seasons_maximum_number[random_seasons-1])
print("random episode: "+ str(random_episode))
final_url = simpsons_url+str(random_seasons)+ "-episode-"+str(random_episode)#
print(final_url)
# return HttpResponse(str(final_url))
time.sleep(10)
return redirect(str(final_url))
@@ -1,3 +0,0 @@
from django.db import models
# Create your models here.
@@ -1,3 +0,0 @@
from django.test import TestCase
# Create your tests here.
@@ -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>')
@@ -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()
@@ -1,123 +0,0 @@
"""
Django settings for 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-71%)_#e#o9-dl2o^6mfud-*rw+4+8vy-nd*bzeier&(34ap-p9'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = ['reverse.tryton.geeraert.eu','192.168.4.100','django.tryton.geeraert.eu']
# 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 = '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 = '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,32 +0,0 @@
"""
URL configuration for 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 docker_connection import views, apps
from random_simpsons import apps as random_simpsons
urlpatterns = [
# 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.simpsons),
# path('docker/<str:action>/<str:id_docker>', docker_connection.apps.docker_call),
]
@@ -1,16 +0,0 @@
"""
WSGI config for 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', 'reverse_proxy.settings')
application = get_wsgi_application()
-123
View File
@@ -1,123 +0,0 @@
"""
Django settings for 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-71%)_#e#o9-dl2o^6mfud-*rw+4+8vy-nd*bzeier&(34ap-p9'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = ['reverse.tryton.geeraert.eu','192.168.4.100']
# 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 = '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 = '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'
-30
View File
@@ -1,30 +0,0 @@
"""
URL configuration for 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 docker_connection 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 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', 'reverse_proxy.settings')
application = get_wsgi_application()

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