#!/usr/bin/python3
import asyncio, traceback
from flask import Flask, request, redirect
from hypercorn.config import Config
from hypercorn.asyncio import serve
app = Flask(__name__)
@app.route("/")
def root():
return """
Gem2Browser
Gem2Browser
"""
@app.route("/gem")
def relay():
url = request.args.get('gemini')
if url == None:
return redirect("/")
code = "Something went wrong...
\n"
title = "Something went wrong..."
try:
raise Exception("Not implemented")
except:
code += traceback.format_exc()
return f'\n{title}{code}'
# Run the Hypercorn ASGI server
conf = Config()
conf.bind = "0.0.0.0:2009"
asyncio.run(serve(app, conf))