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-12-12 07:11:13 +00:00
|
|
|
import configparser
|
|
|
|
|
2024-11-29 15:50:23 +00:00
|
|
|
|
2024-11-15 07:26:13 +00:00
|
|
|
app = Flask(__name__)
|
2024-12-05 11:44:54 +00:00
|
|
|
|
2024-11-15 07:26:13 +00:00
|
|
|
@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-12 07:11:13 +00:00
|
|
|
git_url = parser("site", "git_url")
|
|
|
|
website_url = parser("site", "website_url")
|
|
|
|
return render_template("monitoring.html", git_status = get_status(git_url), website_status = get_status(website_url) )
|
2024-11-29 15:50:23 +00:00
|
|
|
|
|
|
|
def get_status_code(link):
|
|
|
|
requested_site = requests.get(link)
|
|
|
|
return requested_site.status_code
|
|
|
|
|
2024-12-02 11:28:15 +00:00
|
|
|
def get_status(link):
|
2024-12-12 07:11:13 +00:00
|
|
|
try:
|
|
|
|
match get_status_code(link):
|
|
|
|
case 200:
|
|
|
|
return "ONLINE"
|
|
|
|
case _:
|
|
|
|
return "ERROR"
|
|
|
|
except:
|
|
|
|
return "OFFLINE"
|
|
|
|
|
|
|
|
def parser(section, attribute):
|
|
|
|
config = configparser.RawConfigParser()
|
|
|
|
config.read("./adrianux.toml")
|
|
|
|
return config.get(section, attribute)
|
2024-11-29 15:50:23 +00:00
|
|
|
|
2024-11-15 07:26:13 +00:00
|
|
|
if __name__ == "__main__":
|
2024-12-12 07:11:13 +00:00
|
|
|
mode = parser("mode","debug_mode")
|
|
|
|
app.run(debug=mode)
|