-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver_beta.py
40 lines (32 loc) · 1004 Bytes
/
server_beta.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python
import os
import BaseHTTPServer
import urlparse
import socket
import time
import json
import binascii
import sys
import glob
TCP_IP = '192.168.1.7'
TCP_PORT = 23
class RequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
def do_GET(self):
# Send the HTTP headers
self.send_response(200)
self.send_header("Content-type", "text/html")
self.end_headers()
params = urlparse.parse_qs(urlparse.urlparse(self.path).query)
if 'cmd' in params:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((TCP_IP, TCP_PORT))
s.send(bytearray(binascii.unhexlify(params['cmd'][0])))
s.close()
files = glob.glob('1c*')
files.sort()
for a in files:
self.wfile.write('<a href="?cmd='+a+'">'+a+'</a><br>')
# Create the HTTP server
server = BaseHTTPServer.HTTPServer(('192.168.1.11', 8000), RequestHandler)
# Start the server
server.serve_forever()