72 lines
1.8 KiB
Python
72 lines
1.8 KiB
Python
from flask import Flask, render_template, request, send_from_directory
|
|
from flask_minify import minify
|
|
from flask_compress import Compress
|
|
from http.client import responses
|
|
import waitress
|
|
import ping3
|
|
import hashlib
|
|
|
|
isProdution = True
|
|
fwdir = "/dps-750ab-17_idf"
|
|
|
|
# READ README YOU STUPID FUCK
|
|
|
|
app = Flask(__name__.split('.')[0])
|
|
Compress(app)
|
|
if isProdution:
|
|
minify(app=app, html=True, js=True, cssless=True)
|
|
|
|
|
|
def isUp(host: str) -> bool:
|
|
return bool(ping3.ping(host, timeout = 1))
|
|
|
|
@app.route('/')
|
|
def main():
|
|
url = "drath.cc"
|
|
links = ["isheatwork", "manga", "cloud", "movies", "slots"]
|
|
return render_template('index.html.j2', links=sorted(links), url=url)
|
|
|
|
@app.route('/status/funbox')
|
|
def funbox():
|
|
return str(isUp("192.168.1.1"))
|
|
|
|
@app.route('/status/proxmox')
|
|
def proxmox():
|
|
return str(isUp("10.0.1.2"))
|
|
|
|
@app.route('/status/opnsense')
|
|
def opnsense():
|
|
return str(isUp("10.0.1.1"))
|
|
|
|
@app.route('/status/server')
|
|
def server():
|
|
return str(isUp("10.0.1.200"))
|
|
|
|
@app.route('/dps-750ab-17_idf/sha256')
|
|
def psu_sha256():
|
|
with open(fwdir + "/dps-750ab-17_idf.elf", "rb") as f:
|
|
elf = f.read()
|
|
return hashlib.sha256(elf).hexdigest()
|
|
|
|
@app.route('/dps-750ab-17_idf/firmware.bin')
|
|
def psu_firmware():
|
|
return send_from_directory(fwdir, 'dps-750ab-17_idf.bin')
|
|
|
|
@app.route('/http/<status>')
|
|
def httpcodes(status):
|
|
status = int(status.replace('\'', ''))
|
|
return render_template(
|
|
'error.html.j2',
|
|
code=status,
|
|
host="docker host",
|
|
desc=responses[status],
|
|
site=request.host,
|
|
isup="up" if isUp("10.0.1.200") else "down"
|
|
)
|
|
|
|
if __name__ == '__main__':
|
|
if isProdution:
|
|
print("Starting waitress server")
|
|
waitress.serve(app, host='0.0.0.0', port=8080)
|
|
else:
|
|
app.run(host='0.0.0.0', port=8080, debug=True) |