try to work on the redirection
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 3m8s

This commit is contained in:
pierre geeraert
2025-12-08 23:00:46 +00:00
parent 369954f5d2
commit 12253f0621
10 changed files with 342 additions and 3 deletions
+1 -1
View File
@@ -56,7 +56,7 @@ TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
#'DIRS': ["/code/django_code/templates","/code/django_code/dashboard/templates/"],
'DIRS': [BASE_DIR / "templates","django_code/dashboard/templates/","django_code/stash_management/templates"],
'DIRS': [BASE_DIR / "templates","django_code/dashboard/templates/","django_code/stash_management/templates","django_code/website_redirection/templates"],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
+9 -1
View File
@@ -25,6 +25,7 @@ from dashboard import views as dashboardview
from kubernetes_connection import apps as kubernetes_connection
from stash_management import apps as stashapp
from stash_management import views as stashview
from website_redirection import apps as website_redirectionapp
urlpatterns = [
# path('admin/', admin.site.urls),
@@ -34,7 +35,14 @@ urlpatterns = [
path('simpsons/', random_simpsons.simpsons),
path('download_file/', random_simpsons.download_file),
################### paperless ###################
################### Redirect ###################
path('redirect/hello/', website_redirectionapp.hello),
path('redirect/set/', website_redirectionapp.redirect),
path('redirect/get/<str:key>', website_redirectionapp.display_key),
path('redirect/redirect-form/', website_redirectionapp.redirect_process, name='submit_form'),
################### paperless ###################
path('paperless/hello/', paperless_django.hello),
# path('simpsons/', random_simpsons.simpsons),
+1 -1
View File
@@ -176,7 +176,7 @@ def redgif_donloader(username):
# copy as curl and you got the bearer
#curl curl 'https://api.redgifs.com/v2/users/princesspizookie/search?order=new&count=40&type=g'
#and you get the URLS , needs to be parsed
#and you get the URLS , needs to be parsedw
return 0
def incremental(request):
return render(request, 'incremental_form.html',{})
+3
View File
@@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.
+32
View File
@@ -0,0 +1,32 @@
import redis
from django.http import HttpResponse
r = redis.Redis(
host='django-redis-svc',
port=6379,
db=0 # The default Redis database index
)
def hello(request):
return HttpResponse('<h1>Hello redirect!</h1>')
def redirect(request):
return render(request, 'redirect_form.html',{})
def redirect_process(request):
key = request.GET.get('key')
value = request.GET.get('value')
r.set(key, value)
text_generated = "successfully set "+value+" to "+key
return HttpResponse(text_generated, content_type="text/plain")
def display_key(key):
value = r.get(key)
value_extracted = str(value.decode())
text_generated = key+" is set to "+value_extracted
return HttpResponse(text_generated, content_type="text/plain")
@@ -0,0 +1,3 @@
from django.db import models
# Create your models here.
@@ -0,0 +1,282 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Stash form</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto|Varela+Round">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<style>
@charset "UTF-8";
.m-b-xs {
margin-bottom: 2%;
}
.m-b-md {
margin-bottom: 10%;
}
.m-t-xs {
margin-top: 2%;
}
.m-t-sm {
margin-top: 5%;
}
* {
outline: 0 !important;
}
body {
padding: 2% 0;
background-color: #37404a;
}
h1 {
font-family: "Roboto", sans-serif;
font-size: 2.2em;
font-weight: 300;
color: #85ffc7;
text-transform: uppercase;
}
p {
font-family: "Roboto", sans-serif;
font-size: 1.1em;
font-weight: 300;
color: #fff;
}
a {
color: #fff;
}
a:hover {
text-decoration: none;
color: #fff;
}
#survey-form label,
#survey-form .labels {
display: block;
margin-bottom: 2%;
font-family: "Roboto", sans-serif;
font-size: 1.1em;
font-weight: 300;
color: #fff;
letter-spacing: 0.5px;
}
#survey-form input::-webkit-input-placeholder {
color: transparent !important;
}
#survey-form input::-moz-placeholder {
color: transparent !important;
}
#survey-form input:-ms-input-placeholder {
color: transparent !important;
}
#survey-form input:-moz-placeholder {
color: transparent !important;
}
#survey-form input,
#survey-form select {
display: block;
width: 100%;
overflow: hidden;
outline: none;
border: 2px solid #333;
}
#survey-form input {
margin-top: 1.5%;
padding: 0 0 5px 0;
background: transparent;
border: none;
outline: none;
border-bottom: 2px solid #fff;
font-size: 1.1em;
font-weight: 300;
color: #85ffc7;
}
#survey-form input:focus {
border-color: #85ffc7;
}
#survey-form [type=checkbox],
#survey-form [type=radio] {
display: inline-block;
width: auto;
margin: 0px 10px 0 0;
}
#survey-form [type=checkbox],
#survey-form [type=radio] {
display: inline-block;
margin: 0 10px 0 0 !important;
position: relative;
top: 5px;
right: 0;
bottom: 0;
left: 0;
-webkit-appearance: none;
-moz-appearance: none;
-o-appearance: none;
appearance: none;
height: 23px;
width: 23px;
transition: all 0.15s ease-out 0s;
background: #37404a;
color: #fff;
cursor: pointer;
outline: none;
z-index: 1000;
border: 1px solid #fff;
}
#survey-form [type=checkbox]:hover,
#survey-form [type=radio]:hover {
border-color: #85ffc7;
}
#survey-form [type=checkbox]:checked:before,
#survey-form [type=radio]:checked:before {
display: inline-block;
height: 21px;
width: 21px;
position: relative;
left: 0;
bottom: 0;
content: "";
text-align: center;
font-family: "Glyphicons Halflings";
line-height: 20px;
font-size: 15px;
color: #85ffc7;
}
#survey-form [type=checkbox]:focus,
#survey-form [type=radio]:focus {
outline: none;
border-color: #fff;
}
#survey-form [type=radio] {
border-radius: 50%;
}
#survey-form [type=radio]:after {
border-radius: 50%;
}
#survey-form [type=number] {
width: 45px;
}
#survey-form [type=number]::-webkit-inner-spin-button, #survey-form [type=number]::-webkit-outer-spin-button {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
margin: 0;
}
#survey-form select {
height: 40px;
padding-left: 5px;
background-color: #37404a;
border: 2px solid #fff;
color: #85ffc7;
}
#survey-form select option {
padding: 5px 10px;
font-weight: 300;
cursor: pointer;
}
#survey-form select option:hover {
background-color: #85ffc7;
}
#survey-form textarea {
resize: none;
margin-top: 2%;
padding: 10px 10px 0px 20px;
width: 100%;
height: 90px;
color: #85ffc7;
background-color: #37404a;
border: 2px solid #fff;
}
#survey-form .btn {
display: inline-block;
position: relative;
width: 100%;
margin: 3% 0 0 0;
height: 45px;
text-transform: uppercase;
text-decoration: none;
cursor: pointer;
border: 3px solid #85ffc7;
border-radius: 0;
font-weight: 500;
font-size: 1.2em;
color: #85ffc7;
text-align: center;
background: none;
transition: color 0.25s ease;
}
#survey-form .btn:after {
position: absolute;
content: "";
top: 0;
left: 0;
width: 0;
height: 100%;
background-color: #85ffc7;
transform-origin: left;
transition: width 0.5s ease;
z-index: -1;
}
#survey-form .btn:hover {
color: #37404a;
}
#survey-form .btn:hover:after {
width: 100%;
}
#survey-form fieldset {
margin: 5% 0 0 0;
}
.copyright {
text-align: center;
font-size: 10px;
color: #fff;
}
.copyright i {
color: #ef5350;
}
@media only screen and (max-width: 600px) {
body {
padding: 8% 0;
}
}
</style>
</head>
<main id="main" class="container">
<div class="row">
<div class="col-xs-12 col-lg-offset-3 col-lg-6">
<div class="m-b-md text-center">
<h1 id="title">Stash Form</h1>
<p id="description" class="description" class="text-center">Download form</p>
</div>
<form method="GET" action="/redirect/redirect-form/" id="survey-form" name="survey-form">
<fieldset>
<label for="key" id="key-label">
Key *
<input class="" type="text" id="key" name="key" placeholder="Enter your key (required)" required />
</label>
</fieldset>
<fieldset>
<label for="value" id="value-label">
Value *
<input class="" type="value" id="value" name="value" placeholder="Enter the value (required)" required />
</label>
</fieldset>
<button id="submit" type="submit" class="btn">Submit the form</button>
</form>
</div>
</div>
</main>
</html>
+3
View File
@@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.
+8
View File
@@ -0,0 +1,8 @@
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>')