2025-01-12 21:36:58 -08:00
|
|
|
#!/usr/bin/python3
|
|
|
|
import asyncio, traceback
|
2025-01-12 21:47:13 -08:00
|
|
|
from flask import Flask, request, render_template
|
2025-01-12 21:36:58 -08:00
|
|
|
from hypercorn.config import Config
|
|
|
|
from hypercorn.asyncio import serve
|
|
|
|
app = Flask(__name__)
|
|
|
|
@app.route("/")
|
|
|
|
def root():
|
|
|
|
return render_template("home.html")
|
|
|
|
@app.route("/gem/<url>")
|
|
|
|
def relay(url):
|
|
|
|
parsed = "<h1>Something went wrong...</h1>\n"
|
|
|
|
title = "Something went wrong..."
|
|
|
|
try:
|
|
|
|
raise Exception("Not implemented")
|
|
|
|
except:
|
|
|
|
parsed += traceback.format_exc()
|
|
|
|
return render_template("gem.html", code=parsed, title=title)
|
|
|
|
|
|
|
|
# Run the Hypercorn ASGI server
|
2025-01-12 21:49:36 -08:00
|
|
|
conf = Config()
|
|
|
|
conf.bind = "0.0.0.0:2009"
|
|
|
|
asyncio.run(serve(app, conf))
|