Simonc-44 commited on
Commit
f98f153
·
verified ·
1 Parent(s): ef8ccb9

Update server.py

Browse files
Files changed (1) hide show
  1. server.py +194 -1
server.py CHANGED
@@ -1,5 +1,5 @@
1
  from fastapi import FastAPI
2
- from fastapi.responses import StreamingResponse
3
  from pydantic import BaseModel
4
  from transformers import AutoTokenizer, AutoModelForCausalLM, TextIteratorStreamer
5
  import torch
@@ -20,6 +20,199 @@ model = AutoModelForCausalLM.from_pretrained(
20
  class Request(BaseModel):
21
  message: str
22
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
 
24
  @app.post("/chat-stream")
25
  def chat_stream(req: Request):
 
1
  from fastapi import FastAPI
2
+ from fastapi.responses import StreamingResponse, HTMLResponse
3
  from pydantic import BaseModel
4
  from transformers import AutoTokenizer, AutoModelForCausalLM, TextIteratorStreamer
5
  import torch
 
20
  class Request(BaseModel):
21
  message: str
22
 
23
+ @app.get("/", response_class=HTMLResponse)
24
+ def home():
25
+ return """
26
+ <!DOCTYPE html>
27
+ <html lang="en">
28
+ <head>
29
+ <meta charset="UTF-8">
30
+ <title>Server Status</title>
31
+
32
+ <style>
33
+ @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700&display=swap');
34
+
35
+ body {
36
+ margin: 0;
37
+ height: 100vh;
38
+ display: flex;
39
+ justify-content: center;
40
+ align-items: center;
41
+ background: radial-gradient(circle at top, #0b1020, #030712);
42
+ font-family: Inter, sans-serif;
43
+ color: white;
44
+ overflow: hidden;
45
+ }
46
+
47
+ /* background glow */
48
+ .glow {
49
+ position: absolute;
50
+ width: 700px;
51
+ height: 700px;
52
+ background: radial-gradient(circle, rgba(99,102,241,0.25), transparent 60%);
53
+ filter: blur(70px);
54
+ animation: float 6s ease-in-out infinite;
55
+ }
56
+
57
+ @keyframes float {
58
+ 0%,100% { transform: translateY(0px); }
59
+ 50% { transform: translateY(-50px); }
60
+ }
61
+
62
+ /* main card */
63
+ .card {
64
+ position: relative;
65
+ text-align: center;
66
+ padding: 60px 70px;
67
+ border-radius: 28px;
68
+ background: rgba(255,255,255,0.05);
69
+ border: 1px solid rgba(255,255,255,0.08);
70
+ backdrop-filter: blur(22px);
71
+ box-shadow: 0 30px 100px rgba(0,0,0,0.7);
72
+ animation: fadeIn 1.2s ease;
73
+ }
74
+
75
+ @keyframes fadeIn {
76
+ from { opacity: 0; transform: scale(0.9); }
77
+ to { opacity: 1; transform: scale(1); }
78
+ }
79
+
80
+ /* STATUS TEXT */
81
+ .status {
82
+ display: flex;
83
+ align-items: center;
84
+ justify-content: center;
85
+ gap: 14px;
86
+ font-size: 30px;
87
+ font-weight: 600;
88
+ letter-spacing: 1px;
89
+ }
90
+
91
+ /* ULTRA DOT ANIMATION */
92
+ .dot {
93
+ width: 14px;
94
+ height: 14px;
95
+ background: #10b981;
96
+ border-radius: 50%;
97
+ position: relative;
98
+ box-shadow: 0 0 15px rgba(16,185,129,0.9);
99
+ animation: flicker 2.2s ease-in-out infinite;
100
+ }
101
+
102
+ .dot::before {
103
+ content: "";
104
+ position: absolute;
105
+ top: 50%;
106
+ left: 50%;
107
+ width: 100%;
108
+ height: 100%;
109
+ background: #10b981;
110
+ border-radius: 50%;
111
+ transform: translate(-50%, -50%);
112
+ animation: pulse1 1.8s ease-out infinite;
113
+ opacity: 0.6;
114
+ }
115
+
116
+ .dot::after {
117
+ content: "";
118
+ position: absolute;
119
+ top: 50%;
120
+ left: 50%;
121
+ width: 100%;
122
+ height: 100%;
123
+ background: #34d399;
124
+ border-radius: 50%;
125
+ transform: translate(-50%, -50%);
126
+ animation: pulse2 2.4s ease-out infinite;
127
+ opacity: 0.4;
128
+ }
129
+
130
+ @keyframes flicker {
131
+ 0%, 100% { transform: scale(1); opacity: 1; }
132
+ 50% { transform: scale(0.92); opacity: 0.85; }
133
+ }
134
+
135
+ @keyframes pulse1 {
136
+ 0% {
137
+ transform: translate(-50%, -50%) scale(1);
138
+ opacity: 0.7;
139
+ }
140
+ 100% {
141
+ transform: translate(-50%, -50%) scale(3.8);
142
+ opacity: 0;
143
+ }
144
+ }
145
+
146
+ @keyframes pulse2 {
147
+ 0% {
148
+ transform: translate(-50%, -50%) scale(1);
149
+ opacity: 0.5;
150
+ }
151
+ 100% {
152
+ transform: translate(-50%, -50%) scale(5.5);
153
+ opacity: 0;
154
+ }
155
+ }
156
+
157
+ .subtitle {
158
+ margin-top: 14px;
159
+ font-size: 14px;
160
+ color: #9ca3af;
161
+ letter-spacing: 0.4px;
162
+ }
163
+
164
+ .badge {
165
+ margin-top: 22px;
166
+ display: inline-block;
167
+ padding: 6px 14px;
168
+ border-radius: 999px;
169
+ font-size: 12px;
170
+ background: rgba(99,102,241,0.15);
171
+ border: 1px solid rgba(99,102,241,0.35);
172
+ color: #a5b4fc;
173
+ }
174
+
175
+ /* particles */
176
+ .particle {
177
+ position: absolute;
178
+ width: 6px;
179
+ height: 6px;
180
+ background: rgba(255,255,255,0.08);
181
+ border-radius: 50%;
182
+ animation: move 10s linear infinite;
183
+ }
184
+
185
+ @keyframes move {
186
+ from { transform: translateY(0px); opacity: 0; }
187
+ 50% { opacity: 1; }
188
+ to { transform: translateY(-600px); opacity: 0; }
189
+ }
190
+
191
+ </style>
192
+ </head>
193
+
194
+ <body>
195
+
196
+ <div class="glow"></div>
197
+
198
+ <div class="particle" style="left:10%; top:80%;"></div>
199
+ <div class="particle" style="left:30%; top:90%;"></div>
200
+ <div class="particle" style="left:70%; top:85%;"></div>
201
+ <div class="particle" style="left:90%; top:95%;"></div>
202
+
203
+ <div class="card">
204
+
205
+ <div class="status">
206
+ <div class="dot"></div>
207
+ Server Running
208
+ </div>
209
+
210
+ </div>
211
+
212
+ </body>
213
+ </html>
214
+ """
215
+
216
 
217
  @app.post("/chat-stream")
218
  def chat_stream(req: Request):