2021-08-01 01:04:41 +00:00
|
|
|
from os import environ
|
|
|
|
import os
|
|
|
|
from fastapi import FastAPI, Body, Request, Depends
|
|
|
|
import json
|
|
|
|
from fastapi.exceptions import HTTPException
|
|
|
|
|
|
|
|
from fastapi.param_functions import Header
|
|
|
|
from fastapi_responses import custom_openapi
|
|
|
|
from app.auth import auth_hook, auth_web, check_ref
|
|
|
|
from app.pack import Pack
|
|
|
|
|
|
|
|
|
|
|
|
if not os.environ.get("DOCKER"):
|
|
|
|
from dotenv import load_dotenv
|
|
|
|
load_dotenv
|
|
|
|
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
|
|
app.openapi = custom_openapi(app)
|
|
|
|
|
|
|
|
pack = Pack()
|
|
|
|
pack.clone()
|
|
|
|
|
|
|
|
@app.get("/", dependencies=[Depends(auth_web)])
|
|
|
|
@app.post("/", dependencies=[Depends(auth_hook), Depends(check_ref)])
|
|
|
|
async def hook(req: Request):
|
|
|
|
pack.pull()
|
|
|
|
pack.collate()
|
|
|
|
pack.compress()
|
|
|
|
pack.hash()
|
|
|
|
pack.upload()
|
2021-08-01 01:43:22 +00:00
|
|
|
return "Updated " + pack.gethash()
|
2021-08-01 01:04:41 +00:00
|
|
|
|
|
|
|
|