diff --git a/iwm_browser/main.py b/iwm_browser/main.py index fc8bd31..45c561a 100644 --- a/iwm_browser/main.py +++ b/iwm_browser/main.py @@ -33,10 +33,10 @@ async def root(): @app.get("/search", response_class=HTMLResponse) async def search( q: Union[str, None] = None, - p: Union[int, None] = None, - sort: Union[str, None] = None, - dir: Union[str, None] = None, - date: Union[int, None] = None + p: int = 0, + sort: str = "average_Rating", + dir: str = "desc", + date: int = -1 ): template = template_env.get_template("search.html") limit = 10 @@ -60,17 +60,6 @@ async def search( except httpx.ReadTimeout: return "Server timed out" else: - - # Check sort types - if sort is None: - sort = "average_rating" - - if dir is None: - dir = "desc" - - if date is None: - date = -1 - order = {"Dir": dir, "Name": sort} if date == -1: last_x_hours = {} @@ -109,6 +98,25 @@ async def search( entryNumber=entryNumber ) +@app.get("/level/{level_id}", response_class=HTMLResponse) +async def showLevel(level_id: int): + template = template_env.get_template("levelInfo.html") + + try: + rq = httpx.get(BASE_URL + "/api/v1/map/" + str(level_id), timeout=10) + searchResults = rq.json() + print(rq.url) + except httpx.ReadTimeout: + return "Server timed out" + + + + return template.render( + map=searchResults, + THUMB_URL=THUMB_URL, + ) + + def start(): diff --git a/iwm_browser/tags.py b/iwm_browser/tags.py new file mode 100644 index 0000000..cf834f0 --- /dev/null +++ b/iwm_browser/tags.py @@ -0,0 +1,43 @@ +""" +Tag names and corresponding IDs (Shown in the original order) + +0: Adventure/Variety +6: Gimmick +7: Trap/Troll +3: Joke/Meme +2: Needle +5: Puzzle +1: Boss/Avoidance +9: Art +8: Music +4: Auto + +(Yes, if you select all tags, +the required_tags argument will be in that order.) +""" + +ids_to_names = { + 0: "Adventure/Variety", + 6: "Gimmick", + 7: "Trap/Troll", + 3: "Joke/Meme", + 2: "Needle", + 5: "Puzzle", + 1: "Boss/Avoidance", + 9: "Art", + 8: "Music", + 4: "Auto", +} + +names_to_ids = { + "Adventure/Variety": 0, + "Gimmick": 6, + "Trap/Troll": 7, + "Joke/Meme": 3, + "Needle": 2, + "Puzzle": 5, + "Boss/Avoidance": 1, + "Art": 9, + "Music": 8, + "Auto": 4, +} diff --git a/iwm_browser/templates/levelInfo.html b/iwm_browser/templates/levelInfo.html new file mode 100644 index 0000000..40e5e3e --- /dev/null +++ b/iwm_browser/templates/levelInfo.html @@ -0,0 +1,51 @@ + + +
+