This commit is contained in:
parent
d98e9767d3
commit
e696b2a10b
2 changed files with 33 additions and 0 deletions
24
app.py
24
app.py
|
@ -1,5 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
from flask import Flask, render_template, redirect, url_for
|
||||
import requests
|
||||
|
||||
app = Flask(__name__)
|
||||
navigation = {"Imprint":"imprint"}
|
||||
@app.route("/imprint")
|
||||
|
@ -14,5 +16,27 @@ def about():
|
|||
def homepage():
|
||||
return render_template("homepage.html")
|
||||
|
||||
@app.route("/monitoring")
|
||||
def monitoring():
|
||||
git_status = get("http://localhost:5000")
|
||||
website_status = get("http://localhost:5000")
|
||||
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>"
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run(debug=True)
|
||||
|
|
9
templates/monitoring.html
Normal file
9
templates/monitoring.html
Normal file
|
@ -0,0 +1,9 @@
|
|||
{% extends "base.html" %}
|
||||
{% block title %}Monitoring{% endblock %}
|
||||
{% block head %}
|
||||
{{ super() }}
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
<p>Git status: {{ git_status }}</p>
|
||||
<p>Website status: {{ website_status }}</p>
|
||||
{% endblock %}
|
Loading…
Reference in a new issue