mirror of https://gitlab.com/litecord/litecord.git
static: add handler for index using jinja / render_template
- static: add index.html - run: remove index handler
This commit is contained in:
parent
2ac2ac262a
commit
2852f57f96
|
|
@ -1,4 +1,4 @@
|
||||||
from quart import Blueprint, current_app as app
|
from quart import Blueprint, current_app as app, render_template_string
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
bp = Blueprint('static', __name__)
|
bp = Blueprint('static', __name__)
|
||||||
|
|
@ -6,8 +6,16 @@ bp = Blueprint('static', __name__)
|
||||||
|
|
||||||
@bp.route('/<path:path>')
|
@bp.route('/<path:path>')
|
||||||
async def static_pages(path):
|
async def static_pages(path):
|
||||||
|
"""Map requests from / to /static."""
|
||||||
if '..' in path:
|
if '..' in path:
|
||||||
return 'no', 404
|
return 'no', 404
|
||||||
|
|
||||||
static_path = Path.cwd() / Path('static') / path
|
static_path = Path.cwd() / Path('static') / path
|
||||||
return await app.send_static_file(str(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())
|
||||||
|
|
|
||||||
6
run.py
6
run.py
|
|
@ -335,9 +335,3 @@ async def handle_500(err):
|
||||||
'message': repr(err),
|
'message': repr(err),
|
||||||
'internal_server_error': True,
|
'internal_server_error': True,
|
||||||
}), 500
|
}), 500
|
||||||
|
|
||||||
|
|
||||||
@app.route('/')
|
|
||||||
async def index():
|
|
||||||
"""sample index page."""
|
|
||||||
return 'hewwo'
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
{% 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%}
|
||||||
Loading…
Reference in New Issue