From dcdc4265cb5af6ee12c03eb5ab483636e5228fdd Mon Sep 17 00:00:00 2001 From: Kamil118 Date: Sat, 1 Aug 2026 11:42:12 +0000 Subject: [PATCH] updated palworld config and added webpages for simple restore --- homepage/app.py | 37 +++++++ homepage/requirements.txt | 2 + homepage/templates/index.html | 126 ++++++++++++++++++++++++ palworld/adminPage/app.py | 74 ++++++++++++++ palworld/adminPage/requirements.txt | 3 + palworld/adminPage/templates/index.html | 102 +++++++++++++++++++ palworld/compose.yaml | 3 +- 7 files changed, 346 insertions(+), 1 deletion(-) create mode 100644 homepage/app.py create mode 100644 homepage/requirements.txt create mode 100644 homepage/templates/index.html create mode 100644 palworld/adminPage/app.py create mode 100644 palworld/adminPage/requirements.txt create mode 100644 palworld/adminPage/templates/index.html diff --git a/homepage/app.py b/homepage/app.py new file mode 100644 index 0000000..1849373 --- /dev/null +++ b/homepage/app.py @@ -0,0 +1,37 @@ +from flask import Flask, render_template, send_from_directory, abort +import json +import random + +app_base = Flask(__name__) + + +def get_random_image(): + try: + with open("images/images.json") as f: + + images = json.load(f) + return random.choice(images["images"]) + except Exception as e: + return { + "filename": "https://picsum.photos/200/300", + "author": f"{e}", + "source": "picsum.photos" + } + +@app_base.route("/") +def index(): + return render_template( + "index.html", + image=get_random_image() + ) + +@app_base.route("/images/") +def host_image(filename): + try: + return send_from_directory("images",filename) + except Exception: + abort(404) + + +if __name__ == "__main__": + app_base.run(host="0.0.0.0", port=5000) \ No newline at end of file diff --git a/homepage/requirements.txt b/homepage/requirements.txt new file mode 100644 index 0000000..1167f2f --- /dev/null +++ b/homepage/requirements.txt @@ -0,0 +1,2 @@ +Flask +gunicorn \ No newline at end of file diff --git a/homepage/templates/index.html b/homepage/templates/index.html new file mode 100644 index 0000000..7c11d62 --- /dev/null +++ b/homepage/templates/index.html @@ -0,0 +1,126 @@ + + + + The Home of Fluffy Tails + + + + + + + + + + + + + + + + + +
+ +
+ image of a cute foxgirl +
+
Author: {{ image.author }}
+ +
+
+ +
+ Service Status +
+
+ Palworld Server: foxgirls.date:8211 +
+
+ Matrix server: foxgirls.date +
+
+ Contact: @kamil118:foxgirls.date +
+
+ + + + + + +
+
+ Jellyfin +
+
+
+ Nextcloud +
+
+
+ Gitea +
+
+
+ + +
+ + + \ No newline at end of file diff --git a/palworld/adminPage/app.py b/palworld/adminPage/app.py new file mode 100644 index 0000000..70d24d6 --- /dev/null +++ b/palworld/adminPage/app.py @@ -0,0 +1,74 @@ +import os + +import docker +from flask import Flask, render_template, redirect, url_for, Blueprint +from flask_basicauth import BasicAuth + +app_base = Flask(__name__) + +CONTAINER_NAME = os.environ["CONTAINER_NAME"] + +app_base.config["BASIC_AUTH_USERNAME"] = os.environ["USERNAME"] +app_base.config["BASIC_AUTH_PASSWORD"] = os.environ["PASSWORD"] +app_base.config["BASIC_AUTH_FORCE"] = True + +basic_auth = BasicAuth(app_base) + +client = docker.from_env() + +palworld_bp = Blueprint('palworld', __name__, template_folder="templates", url_prefix="/palworld") + + + +def get_container(): + try: + return client.containers.get(CONTAINER_NAME) + except docker.errors.NotFound: + return None + + +@palworld_bp.route("/") +def index(): + container = get_container() + + if container is None: + return f"Container '{CONTAINER_NAME}' not found.", 404 + + try: + container.reload() + running = container.status == "running" + except: + return "There was an issue reading container state", 500 + + return render_template( + "index.html", + running=running, + container_name=CONTAINER_NAME, + ) + + +@palworld_bp.route("/toggle", methods=["POST"]) +def toggle(): + try: + container = get_container() + + if container is None: + return f"Container '{CONTAINER_NAME}' not found.", 404 + + container.reload() + + if container.status == "running": + container.stop() + else: + container.start() + except docker.errors.APIError as err: + return f"There was an issue managing containers\n {err}", 500 + + + return redirect(url_for("palworld.index")) + +app_base.register_blueprint(palworld_bp) + + +if __name__ == "__main__": + app_base.run(host="0.0.0.0", port=5000) \ No newline at end of file diff --git a/palworld/adminPage/requirements.txt b/palworld/adminPage/requirements.txt new file mode 100644 index 0000000..f20b62f --- /dev/null +++ b/palworld/adminPage/requirements.txt @@ -0,0 +1,3 @@ +Flask +docker +gunicorn \ No newline at end of file diff --git a/palworld/adminPage/templates/index.html b/palworld/adminPage/templates/index.html new file mode 100644 index 0000000..0e08b92 --- /dev/null +++ b/palworld/adminPage/templates/index.html @@ -0,0 +1,102 @@ + + + + Container Control + + + + + + +
+ +
+ {{ container_name }} +
+
+ Please don't bully the button. Shutting down the server can take a few seconds. +
+ +
+ + {% if running %} + + + {% else %} + + {% endif %} + +
+ +
+ + + + + \ No newline at end of file diff --git a/palworld/compose.yaml b/palworld/compose.yaml index 3da31c5..e381796 100644 --- a/palworld/compose.yaml +++ b/palworld/compose.yaml @@ -16,7 +16,8 @@ services: PLAYERS: 16 # Optional but recommended SERVER_PASSWORD: ${PASS} MULTITHREADING: true - REST_API_ENABLED: true + AUTO_RESET_GUILD_NO_ONLINE_PLAYERS: False + REST_API_ENABLED: false REST_API_PORT: 8212 TZ: "UTC" ADMIN_PASSWORD: ${ADMIN_PWD}