reach-vb's picture
reach-vb HF staff
Update app.py
d42a49e
raw
history blame
988 Bytes
"""
"""
from fastapi import FastAPI
from fastapi import Request
events = []
app = FastAPI()
@app.get("/")
async def get_events():
return events
@app.post("/webhook")
async def webhook(request: Request):
global events
events += [await request.json()]
for event in events:
page = BeautifulSoup(disc.events[0]._event["data"]["latest"]["raw"])
image_urls = [link.get('src') for link in page.findAll('img')]
data = {
"discussion_number": i,
"data": {
"prompt": disc.title,
"images": image_urls,
}
}
dataset_repo_id = "triple-t/webhook_stable_diffusion_live"
api = HfApi()
path = hf_hub_download(repo_id=dataset_repo_id, filename=file_name, cache_dir="/home/patrick_huggingface_co/image_cache", repo_type="dataset")
api.upload_file(
path_or_fileobj=path,
path_in_repo=file_name,
repo_id=dataset_repo_id,
repo_type="dataset")