Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
|
@@ -744,8 +744,13 @@ async def fetch_latest_api():
|
|
| 744 |
|
| 745 |
@app.get("/", response_class=HTMLResponse)
|
| 746 |
async def root(request: Request):
|
| 747 |
-
|
| 748 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 749 |
|
| 750 |
return f"""
|
| 751 |
<!DOCTYPE html>
|
|
@@ -766,7 +771,7 @@ async def root(request: Request):
|
|
| 766 |
justify-content: center;
|
| 767 |
align-items: center;
|
| 768 |
min-height: 100vh;
|
| 769 |
-
padding: 20px;
|
| 770 |
box-sizing: border-box;
|
| 771 |
}}
|
| 772 |
.container {{
|
|
@@ -776,10 +781,13 @@ async def root(request: Request):
|
|
| 776 |
border: 1px solid rgba(255, 255, 255, 0.1);
|
| 777 |
border-radius: 16px;
|
| 778 |
padding: 40px;
|
| 779 |
-
max-width:
|
| 780 |
width: 100%;
|
| 781 |
box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
|
|
|
|
|
|
|
| 782 |
text-align: center;
|
|
|
|
| 783 |
}}
|
| 784 |
h1 {{
|
| 785 |
font-size: 2.5rem;
|
|
@@ -792,7 +800,6 @@ async def root(request: Request):
|
|
| 792 |
p.status {{
|
| 793 |
font-size: 1.1rem;
|
| 794 |
color: #94a3b8;
|
| 795 |
-
margin-bottom: 30px;
|
| 796 |
display: flex;
|
| 797 |
align-items: center;
|
| 798 |
justify-content: center;
|
|
@@ -806,42 +813,74 @@ async def root(request: Request):
|
|
| 806 |
display: inline-block;
|
| 807 |
box-shadow: 0 0 10px #22c55e;
|
| 808 |
}}
|
| 809 |
-
|
|
|
|
|
|
|
| 810 |
display: flex;
|
| 811 |
-
|
| 812 |
-
|
|
|
|
|
|
|
| 813 |
}}
|
| 814 |
-
|
| 815 |
-
background: rgba(255, 255, 255, 0.
|
| 816 |
-
border: 1px solid rgba(255, 255, 255, 0.
|
| 817 |
-
color: #
|
| 818 |
-
padding:
|
| 819 |
-
border-radius:
|
| 820 |
-
|
| 821 |
-
font-
|
| 822 |
font-weight: 600;
|
|
|
|
| 823 |
transition: all 0.3s ease;
|
| 824 |
-
display: flex;
|
| 825 |
-
justify-content: space-between;
|
| 826 |
-
align-items: center;
|
| 827 |
}}
|
| 828 |
-
|
| 829 |
-
|
| 830 |
-
|
| 831 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 832 |
}}
|
| 833 |
-
|
| 834 |
-
|
| 835 |
-
border-color: rgba(255, 255, 255, 0.4);
|
| 836 |
-
transform: translateY(-2px);
|
| 837 |
-
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
|
| 838 |
}}
|
| 839 |
-
|
| 840 |
-
|
| 841 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 842 |
}}
|
|
|
|
| 843 |
.footer {{
|
| 844 |
-
margin-top:
|
|
|
|
| 845 |
font-size: 0.9rem;
|
| 846 |
color: #64748b;
|
| 847 |
}}
|
|
@@ -849,23 +888,63 @@ async def root(request: Request):
|
|
| 849 |
</head>
|
| 850 |
<body>
|
| 851 |
<div class="container">
|
| 852 |
-
<
|
| 853 |
-
|
|
|
|
|
|
|
| 854 |
|
| 855 |
-
<div class="
|
| 856 |
-
<
|
| 857 |
-
<
|
| 858 |
-
|
| 859 |
-
|
| 860 |
-
|
| 861 |
-
<
|
| 862 |
-
|
| 863 |
-
|
| 864 |
-
|
|
|
|
| 865 |
</div>
|
| 866 |
|
| 867 |
<p class="footer">Cloud Notifier Interface</p>
|
| 868 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 869 |
</body>
|
| 870 |
</html>
|
| 871 |
"""
|
|
|
|
| 744 |
|
| 745 |
@app.get("/", response_class=HTMLResponse)
|
| 746 |
async def root(request: Request):
|
| 747 |
+
# Fetch real-time data internally without an HTTP request overhead
|
| 748 |
+
health_data = await health_check()
|
| 749 |
+
assistant_data = await internal_assistant()
|
| 750 |
+
|
| 751 |
+
# Format nicely as JSON strings
|
| 752 |
+
health_json = json.dumps(health_data, indent=2)
|
| 753 |
+
assistant_json = json.dumps(assistant_data, indent=2)
|
| 754 |
|
| 755 |
return f"""
|
| 756 |
<!DOCTYPE html>
|
|
|
|
| 771 |
justify-content: center;
|
| 772 |
align-items: center;
|
| 773 |
min-height: 100vh;
|
| 774 |
+
padding: 40px 20px;
|
| 775 |
box-sizing: border-box;
|
| 776 |
}}
|
| 777 |
.container {{
|
|
|
|
| 781 |
border: 1px solid rgba(255, 255, 255, 0.1);
|
| 782 |
border-radius: 16px;
|
| 783 |
padding: 40px;
|
| 784 |
+
max-width: 800px;
|
| 785 |
width: 100%;
|
| 786 |
box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
|
| 787 |
+
}}
|
| 788 |
+
.header-info {{
|
| 789 |
text-align: center;
|
| 790 |
+
margin-bottom: 40px;
|
| 791 |
}}
|
| 792 |
h1 {{
|
| 793 |
font-size: 2.5rem;
|
|
|
|
| 800 |
p.status {{
|
| 801 |
font-size: 1.1rem;
|
| 802 |
color: #94a3b8;
|
|
|
|
| 803 |
display: flex;
|
| 804 |
align-items: center;
|
| 805 |
justify-content: center;
|
|
|
|
| 813 |
display: inline-block;
|
| 814 |
box-shadow: 0 0 10px #22c55e;
|
| 815 |
}}
|
| 816 |
+
|
| 817 |
+
/* Tabs Styling */
|
| 818 |
+
.tabs {{
|
| 819 |
display: flex;
|
| 820 |
+
gap: 10px;
|
| 821 |
+
margin-bottom: 20px;
|
| 822 |
+
border-bottom: 1px solid rgba(255,255,255,0.1);
|
| 823 |
+
padding-bottom: 10px;
|
| 824 |
}}
|
| 825 |
+
.tab-btn {{
|
| 826 |
+
background: rgba(255, 255, 255, 0.05);
|
| 827 |
+
border: 1px solid rgba(255, 255, 255, 0.1);
|
| 828 |
+
color: #94a3b8;
|
| 829 |
+
padding: 10px 20px;
|
| 830 |
+
border-radius: 8px;
|
| 831 |
+
cursor: pointer;
|
| 832 |
+
font-family: inherit;
|
| 833 |
font-weight: 600;
|
| 834 |
+
font-size: 1rem;
|
| 835 |
transition: all 0.3s ease;
|
|
|
|
|
|
|
|
|
|
| 836 |
}}
|
| 837 |
+
.tab-btn:hover {{
|
| 838 |
+
background: rgba(255, 255, 255, 0.1);
|
| 839 |
+
color: #e2e8f0;
|
| 840 |
+
}}
|
| 841 |
+
.tab-btn.active {{
|
| 842 |
+
background: rgba(96, 165, 250, 0.2);
|
| 843 |
+
border-color: #60a5fa;
|
| 844 |
+
color: #60a5fa;
|
| 845 |
+
}}
|
| 846 |
+
|
| 847 |
+
/* Content Area */
|
| 848 |
+
.tab-content {{
|
| 849 |
+
display: none;
|
| 850 |
+
animation: fadeIn 0.3s ease-in-out;
|
| 851 |
}}
|
| 852 |
+
.tab-content.active {{
|
| 853 |
+
display: block;
|
|
|
|
|
|
|
|
|
|
| 854 |
}}
|
| 855 |
+
|
| 856 |
+
pre.code-block {{
|
| 857 |
+
background: #0d1117;
|
| 858 |
+
border: 1px solid rgba(255, 255, 255, 0.1);
|
| 859 |
+
padding: 20px;
|
| 860 |
+
border-radius: 12px;
|
| 861 |
+
overflow-x: auto;
|
| 862 |
+
color: #e6edf3;
|
| 863 |
+
font-family: 'Consolas', 'Monaco', monospace;
|
| 864 |
+
font-size: 0.95rem;
|
| 865 |
+
line-height: 1.5;
|
| 866 |
+
box-shadow: inset 0 2px 4px rgba(0,0,0,0.5);
|
| 867 |
+
}}
|
| 868 |
+
|
| 869 |
+
/* JSON Syntax Highlighting Colors */
|
| 870 |
+
.string {{ color: #a5d6ff; }}
|
| 871 |
+
.number {{ color: #79c0ff; }}
|
| 872 |
+
.boolean {{ color: #56d364; }}
|
| 873 |
+
.null {{ color: #ff7b72; }}
|
| 874 |
+
.key {{ color: #7ee787; font-weight: 600; }}
|
| 875 |
+
|
| 876 |
+
@keyframes fadeIn {{
|
| 877 |
+
from {{ opacity: 0; transform: translateY(5px); }}
|
| 878 |
+
to {{ opacity: 1; transform: translateY(0); }}
|
| 879 |
}}
|
| 880 |
+
|
| 881 |
.footer {{
|
| 882 |
+
margin-top: 40px;
|
| 883 |
+
text-align: center;
|
| 884 |
font-size: 0.9rem;
|
| 885 |
color: #64748b;
|
| 886 |
}}
|
|
|
|
| 888 |
</head>
|
| 889 |
<body>
|
| 890 |
<div class="container">
|
| 891 |
+
<div class="header-info">
|
| 892 |
+
<h1>BIP Auto Notifier</h1>
|
| 893 |
+
<p class="status"><span class="indicator"></span> System is Healthy & Tracking 🚀</p>
|
| 894 |
+
</div>
|
| 895 |
|
| 896 |
+
<div class="tabs">
|
| 897 |
+
<button class="tab-btn active" onclick="switchTab('health')">🏥 Health</button>
|
| 898 |
+
<button class="tab-btn" onclick="switchTab('assistant')">🤖 Assistant</button>
|
| 899 |
+
</div>
|
| 900 |
+
|
| 901 |
+
<div id="health" class="tab-content active">
|
| 902 |
+
<pre class="code-block" id="health-json">{health_json}</pre>
|
| 903 |
+
</div>
|
| 904 |
+
|
| 905 |
+
<div id="assistant" class="tab-content">
|
| 906 |
+
<pre class="code-block" id="assistant-json">{assistant_json}</pre>
|
| 907 |
</div>
|
| 908 |
|
| 909 |
<p class="footer">Cloud Notifier Interface</p>
|
| 910 |
</div>
|
| 911 |
+
|
| 912 |
+
<script>
|
| 913 |
+
// Simple Tab Switching Logic
|
| 914 |
+
function switchTab(tabId) {{
|
| 915 |
+
// Update buttons
|
| 916 |
+
document.querySelectorAll('.tab-btn').forEach(btn => btn.classList.remove('active'));
|
| 917 |
+
event.currentTarget.classList.add('active');
|
| 918 |
+
|
| 919 |
+
// Update content
|
| 920 |
+
document.querySelectorAll('.tab-content').forEach(content => content.classList.remove('active'));
|
| 921 |
+
document.getElementById(tabId).classList.add('active');
|
| 922 |
+
}}
|
| 923 |
+
|
| 924 |
+
// Basic JSON Syntax Highlighter
|
| 925 |
+
function syntaxHighlight(json) {{
|
| 926 |
+
json = json.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
| 927 |
+
return json.replace(/("(\\u[a-zA-Z0-9]{{4}}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function (match) {{
|
| 928 |
+
var cls = 'number';
|
| 929 |
+
if (/^"/.test(match)) {{
|
| 930 |
+
if (/:$/.test(match)) {{
|
| 931 |
+
cls = 'key';
|
| 932 |
+
}} else {{
|
| 933 |
+
cls = 'string';
|
| 934 |
+
}}
|
| 935 |
+
}} else if (/true|false/.test(match)) {{
|
| 936 |
+
cls = 'boolean';
|
| 937 |
+
}} else if (/null/.test(match)) {{
|
| 938 |
+
cls = 'null';
|
| 939 |
+
}}
|
| 940 |
+
return '<span class="' + cls + '">' + match + '</span>';
|
| 941 |
+
}});
|
| 942 |
+
}}
|
| 943 |
+
|
| 944 |
+
// Apply highlighting on load
|
| 945 |
+
document.getElementById('health-json').innerHTML = syntaxHighlight(document.getElementById('health-json').innerText);
|
| 946 |
+
document.getElementById('assistant-json').innerHTML = syntaxHighlight(document.getElementById('assistant-json').innerText);
|
| 947 |
+
</script>
|
| 948 |
</body>
|
| 949 |
</html>
|
| 950 |
"""
|