|
5 | 5 |
|
6 | 6 | import os |
7 | 7 | import sys |
8 | | -import threading |
9 | | -from http.server import HTTPServer, BaseHTTPRequestHandler |
10 | | -import socket |
11 | 8 |
|
12 | 9 | # Ensure the correct working directory |
13 | 10 | sys.path.append(os.path.dirname(os.path.abspath(__file__))) |
14 | 11 |
|
15 | 12 | from chix.app import ChiXApp |
16 | 13 |
|
17 | | -# Simple HTTP server that confirms our application is running |
18 | | -class StatusHandler(BaseHTTPRequestHandler): |
19 | | - def do_GET(self): |
20 | | - self.send_response(200) |
21 | | - self.send_header('Content-type', 'text/html') |
22 | | - self.end_headers() |
23 | | - html_content = """ |
24 | | - <!DOCTYPE html> |
25 | | - <html> |
26 | | - <head> |
27 | | - <title>ChiX Editor</title> |
28 | | - <style> |
29 | | - body { |
30 | | - font-family: Arial, sans-serif; |
31 | | - margin: 40px; |
32 | | - line-height: 1.6; |
33 | | - background-color: #1e1e1e; |
34 | | - color: #e0e0e0; |
35 | | - } |
36 | | - h1 { |
37 | | - color: #0078d7; |
38 | | - } |
39 | | - .container { |
40 | | - max-width: 800px; |
41 | | - margin: 0 auto; |
42 | | - padding: 20px; |
43 | | - background-color: #252526; |
44 | | - border-radius: 5px; |
45 | | - box-shadow: 0 0 10px rgba(0,0,0,0.3); |
46 | | - } |
47 | | - .feature { |
48 | | - margin-bottom: 20px; |
49 | | - } |
50 | | - .status { |
51 | | - color: #5cb85c; |
52 | | - font-weight: bold; |
53 | | - } |
54 | | - </style> |
55 | | - </head> |
56 | | - <body> |
57 | | - <div class="container"> |
58 | | - <h1>ChiX Editor</h1> |
59 | | - <p class="status">Editor is running</p> |
60 | | - <p>ChiX is a professional VS Code-inspired C code editor with advanced features.</p> |
61 | | - |
62 | | - <div class="feature"> |
63 | | - <h2>Features</h2> |
64 | | - <ul> |
65 | | - <li>Syntax highlighting for C code</li> |
66 | | - <li>Code intelligence and suggestions</li> |
67 | | - <li>Integrated compiler and debugger</li> |
68 | | - <li>Multi-file project support</li> |
69 | | - <li>Modern UI with themes</li> |
70 | | - </ul> |
71 | | - </div> |
72 | | - |
73 | | - <p>The editor is running in desktop mode. This page confirms the service is active.</p> |
74 | | - </div> |
75 | | - </body> |
76 | | - </html> |
77 | | - """ |
78 | | - self.wfile.write(html_content.encode('utf-8')) |
79 | | - |
80 | | -def start_server(): |
81 | | - # Find an available port, with preference for 5000 |
82 | | - port = 5000 |
83 | | - server_address = ('0.0.0.0', port) |
84 | | - |
85 | | - try: |
86 | | - httpd = HTTPServer(server_address, StatusHandler) |
87 | | - print(f"Starting HTTP server on port {port}") |
88 | | - httpd.serve_forever() |
89 | | - except: |
90 | | - print(f"Could not start server on port {port}") |
91 | | - |
92 | 14 | if __name__ == "__main__": |
93 | | - # Start the HTTP server in a separate thread |
94 | | - server_thread = threading.Thread(target=start_server) |
95 | | - server_thread.daemon = True |
96 | | - server_thread.start() |
97 | | - |
98 | 15 | # Start the ChiX Editor app in the main thread |
99 | 16 | app = ChiXApp() |
100 | 17 | app.start() |
0 commit comments