Update server.py

This commit is contained in:
Nova Cat 2025-01-13 15:55:48 -08:00
parent 23cdd2f7b0
commit b61f1e4c38

View file

@ -12,15 +12,15 @@ def root():
<html> <html>
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<link rel="stylesheet" href="https://swee.codes/style.css"> <link rel="stylesheet" href="/style.css">
<title>Gem2Browser</title> <title>Gem2Browser</title>
</head> </head>
<body> <body>
<center> <center>
<h1>Gem2Browser</h1> <h1>Gem2Browser</h1>
<form action="/gem"> <form action="/gem">
<p style="font-size: 15pt;">gemini://<input class="input" value="geminiprotocol.net" type="text" name="gemini"></p><br> <p>gemini://<input class="input" value="geminiprotocol.net" type="text" name="gemini"></p><br>
<input type="submit" class="download" value="Go!"> <input type="submit" class="go" value="Go!">
</form> </form>
</center> </center>
</body> </body>
@ -30,6 +30,9 @@ def root():
def external(): def external():
return send_file("external.png") return send_file("external.png")
@app.route("/cross-server.png") @app.route("/cross-server.png")
def crosserver():
return send_file("cross-server.png")
@app.route("/style.css")
def crosserver(): def crosserver():
return send_file("cross-server.png") return send_file("cross-server.png")
@app.route("/gem") @app.route("/gem")
@ -95,9 +98,9 @@ def relay():
tempurl = "/".join(url.split("/")[:-1]) + "/" + goto tempurl = "/".join(url.split("/")[:-1]) + "/" + goto
goto = f"/gem?gemini={tempurl}" goto = f"/gem?gemini={tempurl}"
elif prse.scheme != "gemini": elif prse.scheme != "gemini":
extra = "<img src=\"/external.png\">" extra = "<img height=\"6\" src=\"/external.png\">"
elif prse.hostname != urlparse(fulladdr).hostname: elif prse.hostname != urlparse(fulladdr).hostname:
extra = "<img src=\"/cross-server.png\">" extra = "<img height=\"6\" src=\"/cross-server.png\">"
if temp.split(" ") == 1: if temp.split(" ") == 1:
comment = goto comment = goto
else: else:
@ -109,7 +112,7 @@ def relay():
title = "gemini://" + url title = "gemini://" + url
except: except:
code += traceback.format_exc() code += traceback.format_exc()
return f'<!DOCTYPE html>\n<html><head><meta charset="UTF-8"><link rel="stylesheet" href="https://swee.codes/style.css"><title>{title}</title></head><body>{code}</body></html>' return f'<!DOCTYPE html>\n<html><head><meta charset="UTF-8"><link rel="stylesheet" href="/style.css"><title>{title}</title></head><body>{code}</body></html>'
# Run the Hypercorn ASGI server # Run the Hypercorn ASGI server
conf = Config() conf = Config()