Adrianux.net/app.py

43 lines
1.1 KiB
Python
Raw Normal View History

2024-11-15 07:26:13 +00:00
#!/usr/bin/env python3
from flask import Flask, render_template, redirect, url_for
2024-11-29 15:50:23 +00:00
import requests
2024-11-15 07:26:13 +00:00
app = Flask(__name__)
navigation = {"Imprint":"imprint"}
@app.route("/imprint")
def root():
return render_template("imprint.html")
2024-11-12 15:44:04 +00:00
2024-11-15 07:26:13 +00:00
@app.route("/about")
def about():
return render_template("about.html")
2024-11-12 15:44:04 +00:00
2024-11-15 07:26:13 +00:00
@app.route("/")
def homepage():
return render_template("homepage.html")
2024-11-12 15:44:04 +00:00
2024-11-29 15:50:23 +00:00
@app.route("/monitoring")
def monitoring():
2024-12-02 11:07:12 +00:00
git_status = get("https://git.adrianux.net")
website_status = get("https://adrianux.net")
2024-11-29 15:50:23 +00:00
return render_template("monitoring.html", git_status = git_status, website_status = website_status )
def get_status_code(link):
requested_site = requests.get(link)
return requested_site.status_code
def get(link):
match get_status_code(link):
case 200:
print(200)
return "<span style=green>ONLINE</span>"
case 500:
print(500)
return "<span style=orange>ERROR</span>"
case _:
print("OTHER")
return "<span style=red>OFFLINE</span>"
2024-11-15 07:26:13 +00:00
if __name__ == "__main__":
app.run(debug=True)