Commit 2852f57f authored by Luna's avatar Luna 📟

static: add handler for index using jinja / render_template

 - static: add index.html
 - run: remove index handler
parent 2ac2ac26
from quart import Blueprint, current_app as app
from quart import Blueprint, current_app as app, render_template_string
from pathlib import Path
bp = Blueprint('static', __name__)
......@@ -6,8 +6,16 @@ bp = Blueprint('static', __name__)
@bp.route('/<path:path>')
async def static_pages(path):
"""Map requests from / to /static."""
if '..' in path:
return 'no', 404
static_path = Path.cwd() / Path('static') / path
return await app.send_static_file(str(static_path))
@bp.route('/')
async def index_handler():
"""Handler for the index page."""
index_path = Path.cwd() / Path('static') / 'index.html'
return await render_template_string(index_path.read_text())
......@@ -335,9 +335,3 @@ async def handle_500(err):
'message': repr(err),
'internal_server_error': True,
}), 500
@app.route('/')
async def index():
"""sample index page."""
return 'hewwo'
{% block body %}
<center>
<h1>
welcome to a Litecord instance
</h1>
<p>
Litecord is server software that implements
the Discord API.
</p>
<p>
It supports nodeinfo, despise not being part
in any federated network.
</p>
<p>
<a href="https://gitlab.com/luna/litecord">Litecord source code</a>
</p>
<p>
<a href="{{request.protocol}}/nodeinfo/2.0.json">This instance's nodeinfo</a>
</p>
</center>
{% endblock%}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment