This commit is contained in:
Robert Miles 2021-10-13 11:15:38 +00:00
parent 1cb30fb282
commit 057f2f7625
1 changed files with 7 additions and 3 deletions

10
app.py
View File

@ -155,18 +155,22 @@ def ships(request):
@app.route("/ships/(?P<ship>[^/]+)(?:/(?:index\.gmi)?)?") @app.route("/ships/(?P<ship>[^/]+)(?:/(?:index\.gmi)?)?")
@wrap_response() @wrap_response()
def ship(request,ship=None): def ship(request,ship=None):
global DESC_PRE_SHIPS
if ship is None: return Response(Status.BAD_REQUEST,"Bad Request") if ship is None: return Response(Status.BAD_REQUEST,"Bad Request")
print(ship)
ship_unquoted = urllib.parse.unquote(ship) ship_unquoted = urllib.parse.unquote(ship)
print(ship_unquoted)
if not os.path.isdir(os.path.join("/var/gopher",ship_unquoted)): return Response(Status.NOT_FOUND,"Not Found") if not os.path.isdir(os.path.join("/var/gopher",ship_unquoted)): return Response(Status.NOT_FOUND,"Not Found")
print("generator")
def __generator(): def __generator():
description = os.path.join("/var/gopher",ship_unquoted,".description") description = os.path.join("/var/gopher",ship_unquoted,".description")
if os.path.exists(description): if os.path.exists(description):
if ship_unquoted in DESC_PRE: if ship_unquoted in DESC_PRE_SHIPS:
yield "```" yield "```"
yield DESC_PRE[ship_unquoted] yield DESC_PRE_SHIPS[ship_unquoted]
yield "\n" yield "\n"
yield from app.load_file(description) yield from app.load_file(description)
if ship_unquoted in DESC_PRE: if ship_unquoted in DESC_PRE_SHIPS:
yield "```" yield "```"
yield "\n" yield "\n"
if os.path.exists(os.path.join("/var/gopher",ship_unquoted,"ABOUT")): if os.path.exists(os.path.join("/var/gopher",ship_unquoted,"ABOUT")):