Compare commits

..

No commits in common. "25a57d7b0e11c3f3eddba0bc730b39f9f016d7ea" and "baf6b15e17e6f13b554a055abbc7752ee7d14852" have entirely different histories.

7 changed files with 31 additions and 88 deletions

View file

@ -28,7 +28,6 @@ THUMB_URL = "https://images.make.fangam.es"
# \S[A-Z0-9]{8} = without dash, no whitespace # \S[A-Z0-9]{8} = without dash, no whitespace
level_code_regex = re.compile("[A-Z0-9]{4}\-[A-Z0-9]{4}|[A-Z0-9]{8}") level_code_regex = re.compile("[A-Z0-9]{4}\-[A-Z0-9]{4}|[A-Z0-9]{8}")
error_template = template_env.get_template("error.html")
@app.get("/", response_class=HTMLResponse) @app.get("/", response_class=HTMLResponse)
async def root(): async def root():
template = template_env.get_template("home.html") template = template_env.get_template("home.html")
@ -97,16 +96,11 @@ async def search(
"name": search, "name": search,
**last_x_hours, **author **last_x_hours, **author
}, timeout=10) }, timeout=10)
if rq.status_code == 503:
return error_template.render(reason="Server is unavailable right now.")
searchResults = rq.json() searchResults = rq.json()
print(rq.url, p * limit) print(rq.url, p * limit)
except httpx.ReadTimeout: except httpx.ReadTimeout:
return error_template.render(reason="Server timed out") return "Server timed out"
except json.decoder.JSONDecodeError:
return error_template.render(reason="Failed to parse server response.", details=rq.text)
except Exception as exc:
return error_template.render(reason="Uncaught exception", details=exc)
entryNumber=len(searchResults) entryNumber=len(searchResults)
@ -129,16 +123,10 @@ async def showLevel(level_id: int):
try: try:
rq = httpx.get(BASE_URL + "/api/v1/map/" + str(level_id), timeout=10) rq = httpx.get(BASE_URL + "/api/v1/map/" + str(level_id), timeout=10)
if rq.status_code == 503:
return error_template.render(reason="Server is unavailable right now")
searchResults = rq.json() searchResults = rq.json()
print(rq.url) print(rq.url)
except httpx.ReadTimeout: except httpx.ReadTimeout:
return error_template.render(reason="Server timed out") return "Server timed out"
except json.decoder.JSONDecodeError:
return error_template.render(reason="Failed to parse server response.", details=rq.text)
except Exception as exc:
return error_template.render(reason="Uncaught exception", details=exc)
@ -153,16 +141,10 @@ async def showUser(user_id: int):
try: try:
rq = httpx.get(BASE_URL + "/api/v1/user/" + str(user_id), timeout=10) rq = httpx.get(BASE_URL + "/api/v1/user/" + str(user_id), timeout=10)
if status_code == 503:
return error_template.render(reason="Server is unavailable right now")
searchResults = rq.json() searchResults = rq.json()
print(rq.url) print(rq.url)
except httpx.ReadTimeout: except httpx.ReadTimeout:
return error_template.render(reason="Server timed out") return "Server timed out"
except json.decoder.JSONDecodeError:
return error_template.render(reason="Failed to parse server response.", details=rq.text)
except Exception as exc:
return error_template.render(reason="Uncaught exception", details=exc)

View file

@ -1,11 +0,0 @@
body {
font-size: medium;
}
h1 {
font-size: large;
}
details * {
font-size: small;
}

View file

@ -1,3 +1,26 @@
/* .Home {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
}
.contentBox {
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
outline: 2px solid whitesmoke;
padding: 16px;
/* width: 80%; */
/* height: 80%; */
} */
.tileBox { .tileBox {
display: flex; display: flex;
/* outline: 3px dashed pink; */ /* outline: 3px dashed pink; */
@ -36,25 +59,4 @@
.homeTile a:hover { .homeTile a:hover {
color: cyan; color: cyan;
} }
.Home {
font-size: larger;
}
a:link, a:visited {
color: inherit;
text-decoration: initial;
cursor: auto;
}
a:hover {
outline: 2px dotted blue;
}
a:link:active {
color: inherit;
outline: 2px dotted blue;
}

View file

@ -13,7 +13,7 @@ body {
background-color: #20202a; background-color: #20202a;
color: #eee; color: #eee;
font-size: large; font-size: xx-large;
font-family: monospace; font-family: monospace;
} }

View file

@ -4,7 +4,6 @@
} }
.header { .header {
font-size: medium;
text-align: center; text-align: center;
height: min-content; height: min-content;
} }
@ -30,7 +29,7 @@
border-right: 1px dotted white; border-right: 1px dotted white;
font-family: monospace; font-family: monospace;
font-size: medium; font-size: 0.5em;
} }
.searchBar .searchButton { .searchBar .searchButton {

View file

@ -1,26 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="/static/index.css">
<link rel="stylesheet" href="/static/main.css">
<link rel="stylesheet" href="/static/error.css">
</head>
<body>
<div class="Home">
<div class="contentBox">
<div class="header">Something went wrong</div>
<div class="splitter" />
<h1>{{ reason }}</h1>
{% if details %}
<details>
<summary>More details</summary>
<pre>{{ details }}</pre>
</details>
{% endif %}
</div>
</div>
</body>
</html>

View file

@ -6,16 +6,13 @@
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="/static/index.css"> <link rel="stylesheet" href="/static/index.css">
<link rel="stylesheet" href="/static/main.css"> <link rel="stylesheet" href="/static/main.css">
<link rel="stylesheet" href="/static/homepage.css">
</head> </head>
<body> <body>
<div class="Home"> <div class="Home">
<div class="contentBox"> <div class="contentBox">
<div class="header">IWM Browser</div> <div class="header">IWM Browser</div>
<div class="splitter" /> <div class="splitter" />
<div class="tileBox"><a href="/search?q=&sort=average_rating&dir=desc&date=24">Popular ⭐</a></div> <div class="tileBox"><a href="/search">Search</a></div>
<div class="tileBox"><a href="/search?q=&sort=created_at&dir=desc&date=-1">Recent ❓</a></div>
<div class="tileBox"><a href="/search">Search 🔍</a></div>
</div> </div>
</div> </div>
</body> </body>