Spaces:
Sleeping
Sleeping
Priyansh Saxena commited on
Commit ·
b0f7665
1
Parent(s): cb48d61
DEBUG: Add endpoints to diagnose static file serving issues (/debug/files, /debug/css-test)
Browse files
app.py
CHANGED
|
@@ -613,6 +613,72 @@ async def debug_tools():
|
|
| 613 |
"timestamp": datetime.now().isoformat()
|
| 614 |
}
|
| 615 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 616 |
if __name__ == "__main__":
|
| 617 |
import uvicorn
|
| 618 |
logger.info("Starting Web3 Research Co-Pilot...")
|
|
|
|
| 613 |
"timestamp": datetime.now().isoformat()
|
| 614 |
}
|
| 615 |
|
| 616 |
+
@app.get("/debug/files")
|
| 617 |
+
async def debug_files():
|
| 618 |
+
"""Debug endpoint to check static files"""
|
| 619 |
+
import os
|
| 620 |
+
|
| 621 |
+
files_info = {
|
| 622 |
+
"BASE_DIR": BASE_DIR,
|
| 623 |
+
"STATIC_DIR": STATIC_DIR,
|
| 624 |
+
"TEMPLATES_DIR": TEMPLATES_DIR,
|
| 625 |
+
"static_exists": os.path.isdir(STATIC_DIR),
|
| 626 |
+
"templates_exists": os.path.isdir(TEMPLATES_DIR),
|
| 627 |
+
"static_files": [],
|
| 628 |
+
"templates_files": []
|
| 629 |
+
}
|
| 630 |
+
|
| 631 |
+
# List static files
|
| 632 |
+
if os.path.isdir(STATIC_DIR):
|
| 633 |
+
for f in os.listdir(STATIC_DIR):
|
| 634 |
+
fpath = os.path.join(STATIC_DIR, f)
|
| 635 |
+
files_info["static_files"].append({
|
| 636 |
+
"name": f,
|
| 637 |
+
"size": os.path.getsize(fpath),
|
| 638 |
+
"is_file": os.path.isfile(fpath)
|
| 639 |
+
})
|
| 640 |
+
|
| 641 |
+
# List template files
|
| 642 |
+
if os.path.isdir(TEMPLATES_DIR):
|
| 643 |
+
for f in os.listdir(TEMPLATES_DIR):
|
| 644 |
+
fpath = os.path.join(TEMPLATES_DIR, f)
|
| 645 |
+
files_info["templates_files"].append({
|
| 646 |
+
"name": f,
|
| 647 |
+
"size": os.path.getsize(fpath),
|
| 648 |
+
"is_file": os.path.isfile(fpath)
|
| 649 |
+
})
|
| 650 |
+
|
| 651 |
+
return files_info
|
| 652 |
+
|
| 653 |
+
@app.get("/debug/css-test")
|
| 654 |
+
async def debug_css_test():
|
| 655 |
+
"""Test if CSS can be read directly"""
|
| 656 |
+
css_path = os.path.join(STATIC_DIR, "styles.css")
|
| 657 |
+
|
| 658 |
+
try:
|
| 659 |
+
with open(css_path, 'r') as f:
|
| 660 |
+
css_content = f.read()
|
| 661 |
+
|
| 662 |
+
return {
|
| 663 |
+
"success": True,
|
| 664 |
+
"file_exists": True,
|
| 665 |
+
"file_path": css_path,
|
| 666 |
+
"file_size": len(css_content),
|
| 667 |
+
"first_100_chars": css_content[:100],
|
| 668 |
+
"css_variables_found": "CSS Variables" in css_content
|
| 669 |
+
}
|
| 670 |
+
except FileNotFoundError:
|
| 671 |
+
return {
|
| 672 |
+
"success": False,
|
| 673 |
+
"error": f"File not found: {css_path}",
|
| 674 |
+
"file_exists": False
|
| 675 |
+
}
|
| 676 |
+
except Exception as e:
|
| 677 |
+
return {
|
| 678 |
+
"success": False,
|
| 679 |
+
"error": str(e)
|
| 680 |
+
}
|
| 681 |
+
|
| 682 |
if __name__ == "__main__":
|
| 683 |
import uvicorn
|
| 684 |
logger.info("Starting Web3 Research Co-Pilot...")
|