added intern text generator

main
alex 2024-06-24 21:13:25 +02:00
parent 8fb9d31ddd
commit fbacdadd73
3 changed files with 86 additions and 0 deletions

35
deploy-production.sh Executable file
View File

@ -0,0 +1,35 @@
#!/bin/bash
#screen -dmS admin-dashboard-backend | exit 0
#screen -S admin-dashboard-backend -p 0 -X stuff 'go run main.go\n'
# Set variables
BACKUP_DIR="backups"
DATE=$(date +'%Y-%m-%d_%H-%M-%S')
MAIN_FILE="main"
BACKUP_FILE="$BACKUP_DIR/main-$DATE"
MAX_BACKUPS=10
# Create backup directory if it doesn't exist
mkdir -p $BACKUP_DIR
# Check if the main file exists and move it to the backup directory with the current date and time
if [ -f $MAIN_FILE ]; then
mv $MAIN_FILE $BACKUP_FILE
echo "Backup of '$MAIN_FILE' created at '$BACKUP_FILE'"
else
echo "No existing main file to backup."
fi
# Ensure there are at most MAX_BACKUPS backups in the directory
BACKUPS_COUNT=$(ls $BACKUP_DIR | wc -l)
if [ $BACKUPS_COUNT -gt $MAX_BACKUPS ]; then
BACKUPS_TO_DELETE=$(expr $BACKUPS_COUNT - $MAX_BACKUPS)
ls -t $BACKUP_DIR | tail -n $BACKUPS_TO_DELETE | while read -r file; do
rm "$BACKUP_DIR/$file"
echo "Deleted old backup '$BACKUP_DIR/$file'"
done
fi
go build main.go
sudo systemctl restart admin-dashboard-backend.service

View File

@ -0,0 +1,21 @@
{
"category": "Shinnex",
"name": "Interner Texte Generator",
"globalInputs": [],
"tasks": [
{
"name": "Internen finalen Text für 3D Drucker generieren ",
"onFinish": "pause",
"undoPossible": false,
"repeatPossible": true,
"scriptPath": "script.py",
"parameters": [
{
"parameterName": "text_style",
"type": "textarea",
"displayName": "Texteigenschaften (von Shopify Warenkorb kopieren)"
}
]
}
]
}

View File

@ -0,0 +1,30 @@
import requests
import json
import sys
json_object = json.loads(sys.argv[1])
text_style = json_object["text_style"]
if text_style is None:
print("Missing required parameters")
sys.exit(1)
text_style = text_style["value"]
print("text_style", text_style)
response = requests.post(
url="https://render.shinnex.de/intern",
headers={
"X-Api-Key": "OTp2wNND-TWdW-1VIl-jeOI-L10Lc0O6YvDZ",
"Content-Type": "application/json"
},
json={
"data": text_style,
})
if response.status_code != 200:
print(f"Req err, status code: {response.status_code}")
sys.exit(1)
print("res status_code", response.status_code)