updated palworld config and added webpages for simple restore
This commit is contained in:
1 parent
01d5a95476
commit
dcdc4265cb
7 files changed
+346
-1
No files matched your search
@@ -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/<filename>")
|
||||
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)
|
||||
@@ -0,0 +1,2 @@
|
||||
Flask
|
||||
gunicorn
|
||||
@@ -0,0 +1,126 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>The Home of Fluffy Tails</title>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="description" content="The Home of Fluffy Tails">
|
||||
|
||||
<meta property="og:title" content="The Home of Fluffy Tails" />
|
||||
<meta property="og:description" content="The place where foxgirls are adored and worshipped. Banner by asahisa: https://www.pixiv.net/en/artworks/59850237"/>
|
||||
<meta property="og:url" content="https://foxgirls.date" />
|
||||
<meta property="og:image" content="https://foxgirls.date/images/banner.jpg" />
|
||||
<meta name="theme-color" content="#f38bd1" />
|
||||
|
||||
<meta name="twitter:card" content="summary_large_image" />
|
||||
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100vh;
|
||||
background: #222;
|
||||
font-family: Arial, sans-serif;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.container {
|
||||
text-align: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.display-image {
|
||||
max-width: 80%;
|
||||
max-height: 80vh;
|
||||
}
|
||||
.sauce {
|
||||
display:flex;
|
||||
justify-content: center;
|
||||
width: 80%;
|
||||
margin: 10px auto;
|
||||
gap: 20px;
|
||||
}
|
||||
.author {
|
||||
text-align: left;
|
||||
}
|
||||
.source {
|
||||
text-align: right;
|
||||
}
|
||||
.source>a {
|
||||
font-style: italic;
|
||||
color: rgb(159, 159, 159);
|
||||
text-decoration: none;
|
||||
}
|
||||
a {
|
||||
text-decoration: underline;
|
||||
color: white;
|
||||
}
|
||||
|
||||
table, th, td {
|
||||
border: none !important;
|
||||
}
|
||||
|
||||
.showcase {
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
padding-top: 5px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="container">
|
||||
|
||||
<div style="padding: 20px;">
|
||||
<img class="display-image" src="images/{{ image.filename }}" alt="image of a cute foxgirl">
|
||||
<div class="sauce">
|
||||
<div class="author">Author: {{ image.author }}</div>
|
||||
<div class="source"><a href="{{image.source}}">{{image.source}}</a></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<a href="https://uptime.foxgirls.date/status/all">Service Status</a>
|
||||
</div>
|
||||
<div>
|
||||
Palworld Server: foxgirls.date:8211
|
||||
</div>
|
||||
<div>
|
||||
Matrix server: foxgirls.date
|
||||
</div>
|
||||
<div>
|
||||
Contact: @kamil118:foxgirls.date
|
||||
</div>
|
||||
<div style="display: flex; justify-content: center;">
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="showcase">
|
||||
<a href="https://jelly.foxgirls.date/">Jellyfin</a>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="showcase">
|
||||
<a href="https://cloud.foxgirls.date/">Nextcloud</a>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="showcase">
|
||||
<a href="https://git.foxgirls.date/">Gitea</a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -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)
|
||||
@@ -0,0 +1,3 @@
|
||||
Flask
|
||||
docker
|
||||
gunicorn
|
||||
@@ -0,0 +1,102 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Container Control</title>
|
||||
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100vh;
|
||||
background: #222;
|
||||
font-family: Arial, sans-serif;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.container {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.name {
|
||||
margin-bottom: 30px;
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
.info {
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
button {
|
||||
width: 320px;
|
||||
height: 120px;
|
||||
font-size: 42px;
|
||||
border: none;
|
||||
border-radius: 12px;
|
||||
cursor: pointer;
|
||||
color: white;
|
||||
}
|
||||
|
||||
button:disabled {
|
||||
opacity: 0.6;
|
||||
cursor: wait;
|
||||
}
|
||||
|
||||
.running {
|
||||
background: #d9534f;
|
||||
}
|
||||
|
||||
.stopped {
|
||||
background: #5cb85c;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="container">
|
||||
|
||||
<div class="name">
|
||||
{{ container_name }}
|
||||
</div>
|
||||
<div class="info">
|
||||
Please don't bully the button. Shutting down the server can take a few seconds.
|
||||
</div>
|
||||
|
||||
<form action="{{ url_for('palworld.toggle') }}" method="post", onsubmit="disableButton()">
|
||||
|
||||
{% if running %}
|
||||
<button
|
||||
type="submit"
|
||||
class="running"
|
||||
id="toggleButton"
|
||||
onclick="return confirm('Stop the server?')"
|
||||
>
|
||||
Shut Down
|
||||
</button>
|
||||
|
||||
{% else %}
|
||||
<button
|
||||
type="submit"
|
||||
class="stopped"
|
||||
id="toggleButton"
|
||||
>
|
||||
Start
|
||||
</button>
|
||||
{% endif %}
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function disableButton() {
|
||||
const button = document.getElementById("toggleButton");
|
||||
button.disabled = true;
|
||||
button.innerText = "Working...";
|
||||
}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -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}
|
||||
|
||||
Reference in new issue
Block a user