test
This commit is contained in:
parent
a71b8d1ef6
commit
546e6ea3bb
17
app/main.py
17
app/main.py
@ -18,20 +18,6 @@ loop = asyncio.get_running_loop()
|
||||
# JSON cache
|
||||
cached_data = None
|
||||
|
||||
def shows():
|
||||
html = ''
|
||||
global cached_data
|
||||
accepted_D20 = ('Dimension 20', 'Dimension 20 Animated', "Dimension 20's Adventuring Party")
|
||||
for item in cached_data:
|
||||
if 'Dimension 20' in item['SHOW']:
|
||||
if item['SHOW'] in accepted_D20:
|
||||
name = item['SHOW']
|
||||
html += f'<option value="{name}">{name}</option>'
|
||||
else:
|
||||
name = item['SHOW']
|
||||
html += f'<option value="{name}>{name}</option>'
|
||||
return html
|
||||
|
||||
# api
|
||||
@app.get("/dropout/update")
|
||||
async def dropoutUpdate():
|
||||
@ -127,7 +113,6 @@ async def webpage(request: Request):
|
||||
if cached_data is None:
|
||||
await dropoutUpdate()
|
||||
try:
|
||||
html = shows()
|
||||
return templates.TemplateResponse("dropout.html", {"request": request, "shows": html})
|
||||
return templates.TemplateResponse("dropout.html", {"request": request, "data": cached_data})
|
||||
except Exception as e:
|
||||
return JSONResponse(status_code=500, content={"status": "error", "message": str(e)})
|
||||
|
||||
@ -45,7 +45,9 @@
|
||||
<body>
|
||||
<form id="dropout_download">
|
||||
<select class="downloader" name="show" id="download_show">
|
||||
{{ shows | tojson }}
|
||||
{% for item in data %}
|
||||
<option value="{{ item['SHOW'] }}">{{ item['SHOW'] }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<input class="downloader" name="season" type="text" id="download_season" placeholder="Season">
|
||||
<!-- <input class="downloader" name="episode" type="text" id="download_episode" placeholder="Episode"><br> -->
|
||||
@ -67,7 +69,7 @@
|
||||
|
||||
$.ajax({
|
||||
type: 'POST', // Use POST method to send data
|
||||
url: '/dropoutDownloader', // Target URL for the CherryPy handler
|
||||
url: '/dropout/download', // Target URL for the CherryPy handler
|
||||
data: $('#dropout_download').serializeArray(), // Serialize the form data
|
||||
success: function (data) {
|
||||
$('#downloadResult').html(data); // Display the result in the specified div
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user