ParthSadaria commited on
Commit
9b460f3
·
verified ·
1 Parent(s): 3d08c54

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +41 -6
main.py CHANGED
@@ -407,13 +407,48 @@ async def playground():
407
  if html_content is None:
408
  return HTMLResponse(content="<h1>image-playground.html not found</h1>", status_code=404)
409
  return HTMLResponse(content=html_content)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
410
  @app.get("/vetra", response_class=HTMLResponse)
411
- async def playground():
412
- html_content = read_html_file("Vetra.html")
413
- if html_content is None:
414
- return HTMLResponse(content="<h1>image-playground.html not found</h1>", status_code=404)
415
- return HTMLResponse(content=html_content)
416
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
417
  # Model routes
418
  @app.get("/api/v1/models")
419
  @app.get("/models")
 
407
  if html_content is None:
408
  return HTMLResponse(content="<h1>image-playground.html not found</h1>", status_code=404)
409
  return HTMLResponse(content=html_content)
410
+
411
+
412
+
413
+
414
+ # VETRA
415
+ GITHUB_BASE = "https://raw.githubusercontent.com/Parthsadaria/Vetra/main"
416
+
417
+ FILES = {
418
+ "html": "index.html",
419
+ "css": "style.css",
420
+ "js": "script.js"
421
+ }
422
+
423
+ async def get_github_file(filename: str) -> str:
424
+ url = f"{GITHUB_BASE}/{filename}"
425
+ async with httpx.AsyncClient() as client:
426
+ res = await client.get(url)
427
+ return res.text if res.status_code == 200 else None
428
+
429
  @app.get("/vetra", response_class=HTMLResponse)
430
+ async def serve_vetra():
431
+ html = await get_github_file(FILES["html"])
432
+ css = await get_github_file(FILES["css"])
433
+ js = await get_github_file(FILES["js"])
434
+
435
+ if not html:
436
+ return HTMLResponse(content="<h1>index.html not found on GitHub</h1>", status_code=404)
437
+
438
+ final_html = html.replace(
439
+ "</head>",
440
+ f"<style>{css or '/* CSS not found */'}</style></head>"
441
+ ).replace(
442
+ "</body>",
443
+ f"<script>{js or '// JS not found'}</script></body>"
444
+ )
445
+
446
+ return HTMLResponse(content=final_html)
447
+
448
+
449
+
450
+
451
+
452
  # Model routes
453
  @app.get("/api/v1/models")
454
  @app.get("/models")