Compare commits
2 commits
c50e11d0d5
...
5455a4aa14
Author | SHA1 | Date | |
---|---|---|---|
5455a4aa14 | |||
f9312f3b4b |
3 changed files with 55 additions and 1 deletions
|
@ -279,6 +279,31 @@ async def showUser(user_id: int):
|
||||||
THUMB_URL=THUMB_URL,
|
THUMB_URL=THUMB_URL,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@app.get("/embed/level/{level_id}", response_class=HTMLResponse)
|
||||||
|
async def embed_level(level_id: int):
|
||||||
|
template = template_env.get_template("levelCard_embed.html")
|
||||||
|
|
||||||
|
try:
|
||||||
|
rq = httpx.get(BASE_URL + "/api/v1/map/" + str(level_id), timeout=10, proxies=PROXIES)
|
||||||
|
if rq.status_code == 503:
|
||||||
|
return error_template.render(reason="Server is unavailable right now")
|
||||||
|
searchResults = rq.json()
|
||||||
|
print(rq.url)
|
||||||
|
except httpx.ReadTimeout:
|
||||||
|
return error_template.render(reason="Server timed out")
|
||||||
|
except json.decoder.JSONDecodeError:
|
||||||
|
return error_template.render(
|
||||||
|
reason="Failed to parse server response.", details=rq.text
|
||||||
|
)
|
||||||
|
except Exception as exc:
|
||||||
|
print(exc)
|
||||||
|
return error_template.render(reason="Uncaught exception", details=exc)
|
||||||
|
|
||||||
|
return template.render(
|
||||||
|
map=searchResults,
|
||||||
|
THUMB_URL=THUMB_URL,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def start():
|
def start():
|
||||||
"""Launched with `poetry run start` at root level"""
|
"""Launched with `poetry run start` at root level"""
|
||||||
|
|
27
iwm_browser/templates/levelCard_embed.html
Normal file
27
iwm_browser/templates/levelCard_embed.html
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<title>IWM Browser</title>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<link rel="stylesheet" href="{{ combineCSS(
|
||||||
|
'/static/index.css',
|
||||||
|
'/static/main.css',
|
||||||
|
'/static/search/searchResults.css'
|
||||||
|
) }}">
|
||||||
|
<!-- Optional features -->
|
||||||
|
<script>
|
||||||
|
function copy(obj) {
|
||||||
|
// copies the contents of the
|
||||||
|
// input field to clipboard, and
|
||||||
|
// adds the "copied" css class
|
||||||
|
navigator.clipboard.writeText(obj.value);
|
||||||
|
//alert("Level code copied")
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
{% include "levelCard.html" %}
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -1,7 +1,9 @@
|
||||||
<div class='searchBar'>
|
<div class='searchBar'>
|
||||||
<form action="/search" method="get">
|
<form action="/search" method="get">
|
||||||
<div class="search_entry">
|
<div class="search_entry">
|
||||||
{% set QueryValues = "" if not QueryValues %}
|
{% if not QueryValues %}
|
||||||
|
{% set QueryValues = "" %}
|
||||||
|
{% endif %}
|
||||||
<input type='text' id="q" name="q" value='{{ QueryValues["q"] if QueryValues["q"] is not none }}' placeholder="Enter a level name or code"/>
|
<input type='text' id="q" name="q" value='{{ QueryValues["q"] if QueryValues["q"] is not none }}' placeholder="Enter a level name or code"/>
|
||||||
<button class="searchButton" id='searchButton' type='submit'>🔍</button>
|
<button class="searchButton" id='searchButton' type='submit'>🔍</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue