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
|
# JSON cache
|
||||||
cached_data = None
|
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
|
# api
|
||||||
@app.get("/dropout/update")
|
@app.get("/dropout/update")
|
||||||
async def dropoutUpdate():
|
async def dropoutUpdate():
|
||||||
@ -127,7 +113,6 @@ async def webpage(request: Request):
|
|||||||
if cached_data is None:
|
if cached_data is None:
|
||||||
await dropoutUpdate()
|
await dropoutUpdate()
|
||||||
try:
|
try:
|
||||||
html = shows()
|
return templates.TemplateResponse("dropout.html", {"request": request, "data": cached_data})
|
||||||
return templates.TemplateResponse("dropout.html", {"request": request, "shows": html})
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return JSONResponse(status_code=500, content={"status": "error", "message": str(e)})
|
return JSONResponse(status_code=500, content={"status": "error", "message": str(e)})
|
||||||
|
|||||||
@ -45,7 +45,9 @@
|
|||||||
<body>
|
<body>
|
||||||
<form id="dropout_download">
|
<form id="dropout_download">
|
||||||
<select class="downloader" name="show" id="download_show">
|
<select class="downloader" name="show" id="download_show">
|
||||||
{{ shows | tojson }}
|
{% for item in data %}
|
||||||
|
<option value="{{ item['SHOW'] }}">{{ item['SHOW'] }}</option>
|
||||||
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
<input class="downloader" name="season" type="text" id="download_season" placeholder="Season">
|
<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> -->
|
<!-- <input class="downloader" name="episode" type="text" id="download_episode" placeholder="Episode"><br> -->
|
||||||
@ -67,7 +69,7 @@
|
|||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'POST', // Use POST method to send data
|
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
|
data: $('#dropout_download').serializeArray(), // Serialize the form data
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
$('#downloadResult').html(data); // Display the result in the specified div
|
$('#downloadResult').html(data); // Display the result in the specified div
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user