render README.md on index page

This commit is contained in:
Oscar Krause 2022-12-21 07:33:20 +01:00
parent f977f75538
commit 76f997d437
3 changed files with 6 additions and 2 deletions

View File

@ -11,6 +11,7 @@ RUN apk update \
&& apk del build-deps
COPY app /app
COPY README.md /README.md
HEALTHCHECK --start-period=30s --interval=10s --timeout=5s --retries=3 CMD curl --insecure --fail https://localhost/status || exit 1
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "443", "--app-dir", "/app", "--proxy-headers", "--ssl-keyfile", "/app/cert/webserver.key", "--ssl-certfile", "/app/cert/webserver.crt"]

View File

@ -12,7 +12,7 @@ from dateutil.relativedelta import relativedelta
from calendar import timegm
from jose import jws, jwk, jwt
from jose.constants import ALGORITHMS
from starlette.responses import StreamingResponse, JSONResponse
from starlette.responses import StreamingResponse, JSONResponse, HTMLResponse
import dataset
from Crypto.PublicKey import RSA
from Crypto.PublicKey.RSA import RsaKey
@ -53,7 +53,9 @@ def get_token(request: Request) -> dict:
@app.get('/')
async def index():
return JSONResponse({'hello': 'world'})
from markdown import markdown
content = load_file('../README.md').decode('utf-8')
return HTMLResponse(markdown(text=content, extensions=['tables', 'fenced_code', 'md_in_html', 'nl2br', 'toc']))
@app.get('/status')

View File

@ -4,3 +4,4 @@ python-jose==3.3.0
pycryptodome==3.16.0
python-dateutil==2.8.2
dataset==1.5.2
markdown==3.4.1