|
|
@ -1,5 +1,4 @@
|
|
|
|
import time, os
|
|
|
|
import os, sys
|
|
|
|
from datetime import datetime
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from flask import (
|
|
|
|
from flask import (
|
|
|
|
Flask,
|
|
|
|
Flask,
|
|
|
@ -15,7 +14,16 @@ from werkzeug.exceptions import HTTPException
|
|
|
|
|
|
|
|
|
|
|
|
from discord_webhook import DiscordWebhook
|
|
|
|
from discord_webhook import DiscordWebhook
|
|
|
|
|
|
|
|
|
|
|
|
APP_DIST = "Crystal Linux"
|
|
|
|
import yaml
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if os.path.exists("settings.yaml"):
|
|
|
|
|
|
|
|
settings_obj = yaml.safe_load(open("settings.yaml").read().strip())
|
|
|
|
|
|
|
|
APP_DIST = settings_obj["app_dist"]
|
|
|
|
|
|
|
|
CAMP_EXTRA = settings_obj["camp_extra"]
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
print("No 'settings.yaml', exiting")
|
|
|
|
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
|
|
|
|
app = Flask(__name__)
|
|
|
|
app = Flask(__name__)
|
|
|
|
app.secret_key = "SuperStrongAndComplicated"
|
|
|
|
app.secret_key = "SuperStrongAndComplicated"
|
|
|
@ -37,25 +45,54 @@ def oopsie(e):
|
|
|
|
def do_stuff():
|
|
|
|
def do_stuff():
|
|
|
|
if request.method == "GET":
|
|
|
|
if request.method == "GET":
|
|
|
|
return render_template(
|
|
|
|
return render_template(
|
|
|
|
"page.html", dist=APP_DIST, extra=render_template("form.html")
|
|
|
|
"page.html",
|
|
|
|
|
|
|
|
dist=APP_DIST,
|
|
|
|
|
|
|
|
extra=render_template("form.html", dist=APP_DIST, camp_extra=CAMP_EXTRA),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
elif request.method == "POST":
|
|
|
|
elif request.method == "POST":
|
|
|
|
dtag = request.form["discord-tag"]
|
|
|
|
dtag = request.form["discord-tag"]
|
|
|
|
feedback = request.form["feedback"]
|
|
|
|
feedback = request.form["feedback"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fail = False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not "#" in dtag:
|
|
|
|
|
|
|
|
fail = True
|
|
|
|
|
|
|
|
elif len(dtag.split("#")[1]) != 4:
|
|
|
|
|
|
|
|
fail = True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not fail:
|
|
|
|
if not os.path.exists("data"):
|
|
|
|
if not os.path.exists("data"):
|
|
|
|
os.makedirs("data")
|
|
|
|
os.makedirs("data")
|
|
|
|
if os.path.exists("data/" + dtag):
|
|
|
|
if os.path.exists("data/" + dtag):
|
|
|
|
return "Already submitted"
|
|
|
|
return render_template(
|
|
|
|
|
|
|
|
"page.html",
|
|
|
|
|
|
|
|
dist=APP_DIST,
|
|
|
|
|
|
|
|
extra="<p style='color:red;'>This user has submitted before.</p>",
|
|
|
|
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
with open("data/" + dtag, "w") as f:
|
|
|
|
with open("data/" + dtag, "w") as f:
|
|
|
|
f.write(feedback)
|
|
|
|
f.write(feedback)
|
|
|
|
content = f"User: `{dtag}` submitted the following:\n```{feedback}\n```"
|
|
|
|
content = f"User: `{dtag}` submitted the following:\n```{feedback}\n```"
|
|
|
|
webhook = DiscordWebhook(url=open(".webhook").read().strip(), content=content)
|
|
|
|
webhook = DiscordWebhook(
|
|
|
|
|
|
|
|
url=open(".webhook").read().strip(), content=content
|
|
|
|
|
|
|
|
)
|
|
|
|
response = webhook.execute()
|
|
|
|
response = webhook.execute()
|
|
|
|
return "Thanks!"
|
|
|
|
return render_template(
|
|
|
|
|
|
|
|
"page.html", dist=APP_DIST, extra="<p>Thanks for your feedback!</p>"
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return render_template(
|
|
|
|
|
|
|
|
"page.html",
|
|
|
|
|
|
|
|
dist=APP_DIST,
|
|
|
|
|
|
|
|
extra=f"<p style='color:red;'>Funky discord tag you got there: '{dtag}'</p>",
|
|
|
|
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
return "How did we get here?"
|
|
|
|
return "How did we get here?"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
if __name__ == "__main__":
|
|
|
|
app.run(host="0.0.0.0", port=9090, debug=True)
|
|
|
|
app.run(
|
|
|
|
|
|
|
|
host=settings_obj["host"],
|
|
|
|
|
|
|
|
port=settings_obj["port"],
|
|
|
|
|
|
|
|
debug=settings_obj["debug"],
|
|
|
|
|
|
|
|
)
|
|
|
|