Move hotspots to separate service

This commit is contained in:
2024-04-14 11:16:04 -05:00
parent 6dbb44f5c0
commit 7ae923d58f
11 changed files with 38 additions and 2421 deletions

View File

@@ -1,8 +1,9 @@
import flask
from flask_minify import Minify
import json
from tasks import TaskHandler
import werkzeug.exceptions as HTTPerror
import requests
from config import *
proj = json.load(open("./static/json/projects.json", "r"))
books = json.load(open("./static/json/books.json", "r"))
@@ -16,8 +17,6 @@ pages['home']['books'] = books
pages['books']['books'] = books
app = flask.Flask(__name__)
tasks = TaskHandler()
@app.route('/api/goto/')
@app.route('/api/goto/<location>')
@@ -32,11 +31,6 @@ def goto(location='home'):
page = page404(e)
return [pagevars, page]
# I am literally insane
# There was no reason for me to do this
# it saved some lines of code I guess
# infinite flaskless flask here we comes
def funcGen(pagename, pages):
def dynamicRule():
try:
@@ -62,16 +56,17 @@ def resume():
@app.route("/hotspots")
def hotspotsRIT():
return flask.render_template("hotspots.html")
@app.route("/hotspotsrit/cached")
def getCached():
return json.dumps(tasks.getCache())
@app.route("/hotspotsrit/current")
def getLive():
return json.dumps(tasks.getCurrent())
pagevars = {
"template": "iframe.html",
"title": f"Hotspots @ RIT",
"description": "Hotspots @ RIT by Andrew Simonson",
"canonical": "/hotspots",
}
return flask.render_template("iframe.html", url=HotspotsURL, var=pagevars)
@app.route("/hotspots/<path>")
def hotspotsProxy(path):
return requests.get(f"{HotspotsURL}/{path}").content
@app.errorhandler(Exception)
def page404(e):