Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -15,9 +15,69 @@ client = OpenAI(base_url=endpoint,api_key=GITHUB_TOKEN)
|
|
15 |
request_count = 0
|
16 |
start_time = time.time()
|
17 |
|
|
|
|
|
18 |
@app.route('/')
|
19 |
def home():
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
@app.route('/status', methods=['GET'])
|
23 |
def status():
|
|
|
15 |
request_count = 0
|
16 |
start_time = time.time()
|
17 |
|
18 |
+
from flask import render_template_string
|
19 |
+
|
20 |
@app.route('/')
|
21 |
def home():
|
22 |
+
uptime_seconds = int(time.time() - start_time)
|
23 |
+
days, hours, minutes, seconds = (
|
24 |
+
uptime_seconds // 86400,
|
25 |
+
(uptime_seconds % 86400) // 3600,
|
26 |
+
(uptime_seconds % 3600) // 60,
|
27 |
+
uptime_seconds % 60,
|
28 |
+
)
|
29 |
+
|
30 |
+
uptime_str = f"{days} days, {hours} hours, {minutes} minutes and {seconds} seconds"
|
31 |
+
|
32 |
+
html_template = """
|
33 |
+
<!DOCTYPE html>
|
34 |
+
<html lang="en">
|
35 |
+
<head>
|
36 |
+
<meta charset="UTF-8">
|
37 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
38 |
+
<title>TrueSyncAI API</title>
|
39 |
+
<style>
|
40 |
+
body {
|
41 |
+
font-family: Arial, sans-serif;
|
42 |
+
text-align: center;
|
43 |
+
background-color: #f4f4f4;
|
44 |
+
padding: 40px;
|
45 |
+
}
|
46 |
+
.container {
|
47 |
+
background: white;
|
48 |
+
padding: 20px;
|
49 |
+
border-radius: 10px;
|
50 |
+
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
|
51 |
+
max-width: 500px;
|
52 |
+
margin: auto;
|
53 |
+
}
|
54 |
+
img {
|
55 |
+
width: 100%;
|
56 |
+
max-width: 400px;
|
57 |
+
border-radius: 10px;
|
58 |
+
}
|
59 |
+
h1 {
|
60 |
+
color: #333;
|
61 |
+
}
|
62 |
+
p {
|
63 |
+
font-size: 18px;
|
64 |
+
color: #555;
|
65 |
+
}
|
66 |
+
</style>
|
67 |
+
</head>
|
68 |
+
<body>
|
69 |
+
<div class="container">
|
70 |
+
<img src="https://huggingface.co/spaces/sujalrajpoot/truesyncai/resolve/main/TrueSyncAI.jpg" alt="TrueSyncAI Logo">
|
71 |
+
<h1>TrueSyncAI API</h1>
|
72 |
+
<p><strong>Status:</strong> API is running</p>
|
73 |
+
<p><strong>Total Requests:</strong> {{ total_requests }}</p>
|
74 |
+
<p><strong>Uptime:</strong> {{ uptime }}</p>
|
75 |
+
</div>
|
76 |
+
</body>
|
77 |
+
</html>
|
78 |
+
"""
|
79 |
+
|
80 |
+
return render_template_string(html_template, total_requests=request_count, uptime=uptime_str)
|
81 |
|
82 |
@app.route('/status', methods=['GET'])
|
83 |
def status():
|