Spaces:
Runtime error
Runtime error
File size: 988 Bytes
c2f31df 0d68e6c c2f31df 0d68e6c c2f31df 0d68e6c d42a49e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
"""
"""
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") |