MTayyaBH commited on
Commit
a3815f8
·
1 Parent(s): 336ecea

Add Docker deployment starter for Hugging Face Space

Browse files
Files changed (2) hide show
  1. Dockerfile +10 -0
  2. app.py +50 -0
Dockerfile ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.11-slim
2
+
3
+ WORKDIR /app
4
+
5
+ COPY app.py /app/app.py
6
+
7
+ ENV PORT=7860
8
+ EXPOSE 7860
9
+
10
+ CMD ["python", "app.py"]
app.py ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from http.server import BaseHTTPRequestHandler, HTTPServer
3
+
4
+
5
+ class Handler(BaseHTTPRequestHandler):
6
+ def do_GET(self):
7
+ if self.path == "/health":
8
+ self.send_response(200)
9
+ self.send_header("Content-Type", "text/plain; charset=utf-8")
10
+ self.end_headers()
11
+ self.wfile.write(b"ok")
12
+ return
13
+
14
+ self.send_response(200)
15
+ self.send_header("Content-Type", "text/html; charset=utf-8")
16
+ self.end_headers()
17
+ self.wfile.write(
18
+ b"""<!doctype html>
19
+ <html>
20
+ <head>
21
+ <meta charset="utf-8" />
22
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
23
+ <title>Chatbolt Dev</title>
24
+ <style>
25
+ body { font-family: Arial, sans-serif; padding: 2rem; background: #f5f7fb; color: #1e293b; }
26
+ .card { max-width: 720px; margin: 0 auto; background: #fff; border-radius: 12px; padding: 1.5rem; box-shadow: 0 4px 18px rgba(15,23,42,0.08); }
27
+ h1 { margin-top: 0; }
28
+ code { background: #eef2ff; padding: 0.15rem 0.35rem; border-radius: 6px; }
29
+ </style>
30
+ </head>
31
+ <body>
32
+ <div class="card">
33
+ <h1>Chatbolt Dev Space is running</h1>
34
+ <p>Docker deployment completed successfully.</p>
35
+ <p>Health check endpoint: <code>/health</code></p>
36
+ </div>
37
+ </body>
38
+ </html>"""
39
+ )
40
+
41
+
42
+ def main():
43
+ port = int(os.getenv("PORT", "7860"))
44
+ server = HTTPServer(("0.0.0.0", port), Handler)
45
+ print(f"Server listening on 0.0.0.0:{port}")
46
+ server.serve_forever()
47
+
48
+
49
+ if __name__ == "__main__":
50
+ main()