Add server.py
This commit is contained in:
parent
da30a75c42
commit
8b8649c861
1 changed files with 21 additions and 0 deletions
21
server.py
Normal file
21
server.py
Normal file
|
@ -0,0 +1,21 @@
|
|||
#!/usr/bin/python3
|
||||
import asyncio, traceback
|
||||
from Flask import flask, request, render_template
|
||||
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
|
||||
asyncio.run(serve(app, Config()))
|
Loading…
Add table
Reference in a new issue