From 28b2c39c4ca11e8a249b73b905e531c74cc4ce44 Mon Sep 17 00:00:00 2001 From: Anson Date: Fri, 28 Feb 2020 20:09:42 -0700 Subject: [PATCH] added landing page --- main.py | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 5c3ce50..8c4feb0 100644 --- a/main.py +++ b/main.py @@ -1,17 +1,44 @@ from fastapi import FastAPI import json import random +from starlette.responses import HTMLResponse quotes = json.load(open("quotes.json")) app = FastAPI() -@app.get("/") +@app.get("/api") async def quote(): return {"message": random.choice(quotes)} -@app.get("/dump") +@app.get("/api/dump") async def dump(): return quotes + + +@app.get("/", response_class=HTMLResponse) +async def index(): + quote = random.choice(quotes) + return f""" + + + {quote} + + +

{quote.replace('/','
')}

+ + + """