diff options
Diffstat (limited to 'app.py')
-rw-r--r-- | app.py | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/app.py b/app.py index 873c99b..7262e63 100644 --- a/app.py +++ b/app.py @@ -1,10 +1,11 @@ import os -from os import listdir -from os.path import isfile, join + from dotenv import load_dotenv from pituophis import Item, serve from pyfiglet import Figlet + import news +import sports import weather load_dotenv() @@ -20,16 +21,13 @@ def handle(request): menu.append(Item(itype="1", text="......NEWS", path="/news", host=os.getenv("HOSTNAME"))) menu.append( Item(itype="7", text="......WEATHER (type in city name)", path="/weather", host=os.getenv("HOSTNAME"))) - menu.append(Item(itype="1", text="......OWNER'S SITE", path="/personal", host=os.getenv("HOSTNAME"))) + menu.append(Item(itype="1", text="......SPORTS", path="/sports", host=os.getenv("HOSTNAME"))) return menu elif request.path.startswith("/newstxt"): return news.get_newstxt(request.path.split("?article=")[1]) elif request.path.startswith("/weathertxt"): return weather.get_weather(request.path) - elif request.path == "/personal": - with open("personal/gophermap", "r") as f: - return [i for i in f.readlines()] - elif request.path == "/news" or request.path == "/weather": + elif request.path == "/news" or request.path == "/weather" or request.path == "/sports": menu = [] text = figlet.renderText(request.path[1:]).split("\n") menu += [Item(text=i) for i in text] @@ -39,9 +37,17 @@ def handle(request): menu += news.get_news() case "/weather": menu += weather.get_cities(request.query) + case "/sports": + menu += [ + menu.append(Item(itype="0", text="FORMULA 1", path="/sports/f1", host=os.getenv("HOSTNAME"))) + ] return menu + elif request.path.startswith("/sports/"): + match request.path: + case "/sports/f1": + return sports.get_f1() else: return [Item(itype="3", text="Page not found")] -serve(port=70, handler=handle) +serve(port=70, handler=handle, pub_dir="personal") |