From 1ddd966b385c68af181f4ca60fe188981e736ae8 Mon Sep 17 00:00:00 2001
From: Jimmy <git@jimmy.nz>
Date: Mon, 26 Jul 2021 21:02:22 +1200
Subject: [PATCH] Switch to fastapi

---
 src/main.py | 33 ++++++++++++++++++++++-----------
 1 file changed, 22 insertions(+), 11 deletions(-)

diff --git a/src/main.py b/src/main.py
index 50f898a..0ba8661 100644
--- a/src/main.py
+++ b/src/main.py
@@ -1,14 +1,25 @@
-from aiohttp import web
+from os import environ
+import os
+from fastapi import FastAPI, Body, Request, Depends
+import json
+from fastapi.exceptions import HTTPException
 
-async def handle(request):
-    name = request.match_info.get('name', "Anonymous")
-    text = "Hello, " + name
-    return web.Response(text=text)
+from fastapi.param_functions import Header
+from fastapi_responses import custom_openapi
+from auth import auth_hook, auth_web, check_ref
+
+
+if not os.environ.get("DOCKER"):
+    from dotenv import load_dotenv
+    load_dotenv
+    
+app = FastAPI()
+
+app.openapi = custom_openapi(app)
+
+@app.get("/", dependencies=[Depends(auth_web)])
+@app.post("/", dependencies=[Depends(auth_hook), Depends(check_ref)])
+async def hook(req: Request):
+    return "Update"
 
-app = web.Application()
-app.add_routes([web.get('/', handle),
-                web.get('/{name}', handle)])
 
-if __name__ == '__main__':
-    print("Starting")
-    web.run_app(app)
\ No newline at end of file