From 1b996e2599ee798cbcd0740cd83aa24d3f27f504 Mon Sep 17 00:00:00 2001 From: swee Date: Sun, 12 Jan 2025 22:00:24 -0800 Subject: [PATCH] Update server.py --- server.py | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/server.py b/server.py index 76029a8..c37324a 100644 --- a/server.py +++ b/server.py @@ -1,24 +1,43 @@ #!/usr/bin/python3 import asyncio, traceback -from flask import Flask, request, render_template, redirect +from flask import Flask, request, redirect from hypercorn.config import Config from hypercorn.asyncio import serve app = Flask(__name__) @app.route("/") def root(): - return render_template("home.html") + return """ + + + + + + Gem2Browser + + +
+

Gem2Browser

+
+

gemini://


+ +
+
+ + + """ @app.route("/gem") def relay(): url = request.args.get('gemini') if url == None: return redirect("/") - parsed = "

Something went wrong...

\n" + code = "

Something went wrong...

\n" title = "Something went wrong..." try: raise Exception("Not implemented") except: - parsed += traceback.format_exc() - return render_template("gem.html", code=parsed, title=title) + code += traceback.format_exc() + return f'\n{title}{code} +' # Run the Hypercorn ASGI server conf = Config()