Small fixes
This commit is contained in:
@@ -453,24 +453,36 @@ def admin_update_server():
|
|||||||
return redirect(url_for("admin_login"))
|
return redirect(url_for("admin_login"))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
output = subprocess.check_output(["git", "pull", "origin", "main"], cwd=os.getcwd()).decode()
|
repo_dir = os.path.abspath(os.path.dirname(__file__)) # Dynamically get current project directory
|
||||||
flash("✅ Server updated successfully!<br><pre>" + html.escape(output) + "</pre>", "update")
|
repo_url = "https://github.com/TySP-Dev/PacCrypt.git"
|
||||||
except subprocess.CalledProcessError as e:
|
|
||||||
flash("❌ Failed to update server:<br><pre>" + html.escape(e.output.decode()) + "</pre>", "update")
|
# Ensure directory is a git repo
|
||||||
except Exception as ex:
|
if not os.path.exists(os.path.join(repo_dir, ".git")):
|
||||||
flash("❌ An error occurred: " + str(ex), "update")
|
return redirect(url_for('500.html'))
|
||||||
|
|
||||||
|
# Pull latest changes
|
||||||
|
subprocess.run(["git", "fetch"], cwd=repo_dir, check=True)
|
||||||
|
subprocess.run(["git", "reset", "--hard", "origin/main"], cwd=repo_dir, check=True)
|
||||||
|
subprocess.run(["git", "pull", repo_url, "main"], cwd=repo_dir, check=True)
|
||||||
|
|
||||||
|
flash("Server updated from GitHub!", "clear-feedback")
|
||||||
|
except Exception as e:
|
||||||
|
flash(f"Update failed: {str(e)}", "clear-feedback")
|
||||||
|
|
||||||
return redirect(url_for("admin_page"))
|
return redirect(url_for("admin_page"))
|
||||||
|
|
||||||
@app.route("/sitemap")
|
|
||||||
|
@app.route("/sitemap", methods=["GET"])
|
||||||
def sitemap():
|
def sitemap():
|
||||||
output = ["<h1>PacCrypt Sitemap</h1>", "<ul>"]
|
sitemap_xml = '''<?xml version="1.0" encoding="UTF-8"?>
|
||||||
for rule in app.url_map.iter_rules():
|
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||||
if rule.endpoint != 'static':
|
<url><loc>https://paccrypt.unnaturalll.dev/</loc></url>
|
||||||
url = url_for(rule.endpoint, **{arg: f"<{arg}>" for arg in rule.arguments})
|
<url><loc>https://paccrypt.unnaturalll.dev/pickup</loc></url>
|
||||||
output.append(f"<li><a href='{url}'>{url}</a></li>")
|
<url><loc>https://paccrypt.unnaturalll.dev/adminpage</loc></url>
|
||||||
output.append("</ul>")
|
<url><loc>https://paccrypt.unnaturalll.dev/sitemap</loc></url>
|
||||||
return "\n".join(output)
|
</urlset>'''
|
||||||
|
return sitemap_xml, 200, {'Content-Type': 'application/xml'}
|
||||||
|
|
||||||
|
|
||||||
@app.route("/robots.txt")
|
@app.route("/robots.txt")
|
||||||
def robots_txt():
|
def robots_txt():
|
||||||
|
|||||||
Reference in New Issue
Block a user