OsamaBinLikhon commited on
Commit
9c80792
·
verified ·
1 Parent(s): 8024f72

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +110 -0
app.py ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ Simple test application to demonstrate the antigravity package
4
+ This will run a basic web interface to show the antigravity functionality
5
+ """
6
+
7
+ from http.server import HTTPServer, BaseHTTPRequestHandler
8
+ import subprocess
9
+ import sys
10
+ import os
11
+
12
+ class AntigravityHandler(BaseHTTPRequestHandler):
13
+ def do_GET(self):
14
+ if self.path == '/':
15
+ self.send_response(200)
16
+ self.send_header('Content-type', 'text/html')
17
+ self.end_headers()
18
+
19
+ # Test antigravity package
20
+ try:
21
+ # Try to run antigravity command
22
+ result = subprocess.run(['antigravity', '--help'],
23
+ capture_output=True, text=True, timeout=5)
24
+ antigravity_status = "Available" if result.returncode == 0 else "Error"
25
+ antigravity_output = result.stdout if result.returncode == 0 else result.stderr
26
+ except Exception as e:
27
+ antigravity_status = "Error"
28
+ antigravity_output = str(e)
29
+
30
+ # System info
31
+ system_info = subprocess.run(['uname', '-a'], capture_output=True, text=True)
32
+
33
+ html = f"""
34
+ <!DOCTYPE html>
35
+ <html>
36
+ <head>
37
+ <title>Antigravity Docker Sandbox</title>
38
+ <style>
39
+ body {{ font-family: Arial, sans-serif; margin: 40px; background: #f0f0f0; }}
40
+ .container {{ background: white; padding: 20px; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }}
41
+ .status {{ padding: 10px; margin: 10px 0; border-radius: 4px; }}
42
+ .success {{ background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }}
43
+ .error {{ background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }}
44
+ pre {{ background: #f8f9fa; padding: 15px; border-radius: 4px; overflow-x: auto; }}
45
+ </style>
46
+ </head>
47
+ <body>
48
+ <div class="container">
49
+ <h1>🚀 Antigravity Docker Sandbox</h1>
50
+ <p>This is a Docker-based Ubuntu environment with the antigravity package installed.</p>
51
+
52
+ <h2>System Information</h2>
53
+ <div class="status success">
54
+ <strong>Platform:</strong> Ubuntu Docker Container<br>
55
+ <strong>Python Version:</strong> {sys.version}<br>
56
+ <strong>Working Directory:</strong> {os.getcwd()}
57
+ </div>
58
+
59
+ <h2>Antigravity Package Status</h2>
60
+ <div class="status {'success' if antigravity_status == 'Available' else 'error'}">
61
+ <strong>Status:</strong> {antigravity_status}
62
+ </div>
63
+
64
+ <h3>Antigravity Command Output:</h3>
65
+ <pre>{antigravity_output}</pre>
66
+
67
+ <h3>System Details:</h3>
68
+ <pre>{system_info.stdout}</pre>
69
+
70
+ <p><em>Container is running on Hugging Face Spaces</em></p>
71
+ </div>
72
+ </body>
73
+ </html>
74
+ """
75
+
76
+ self.wfile.write(html.encode())
77
+
78
+ elif self.path == '/api/status':
79
+ self.send_response(200)
80
+ self.send_header('Content-type', 'application/json')
81
+ self.end_headers()
82
+
83
+ import json
84
+ status_data = {
85
+ 'status': 'running',
86
+ 'antigravity_available': antigravity_status == 'Available',
87
+ 'platform': 'Ubuntu Docker',
88
+ 'python_version': sys.version
89
+ }
90
+ self.wfile.write(json.dumps(status_data).encode())
91
+ else:
92
+ self.send_response(404)
93
+ self.end_headers()
94
+
95
+ def log_message(self, format, *args):
96
+ print(f"[Server] {format % args}")
97
+
98
+ def main():
99
+ port = int(os.environ.get('PORT', 7860))
100
+ server = HTTPServer(('0.0.0.0', port), AntigravityHandler)
101
+ print(f"🚀 Antigravity Docker Sandbox running on port {port}")
102
+ print(f"Access at: http://localhost:{port}")
103
+ try:
104
+ server.serve_forever()
105
+ except KeyboardInterrupt:
106
+ print("\nShutting down server...")
107
+ server.shutdown()
108
+
109
+ if __name__ == '__main__':
110
+ main()