Skip to content

Commit

Permalink
First commit for ts3http - a webinterface to manage all instances. Cu…
Browse files Browse the repository at this point in the history
…rrently listens on Port 8080. Not functional. Does only give you the html file back. Neccessary changes to the plugins directory structure are made before. We can now simply add templates for each plugin and provide a solid webinterface. The webinterface itself currently listens on every interface! If you plan to use ts3eventscripts you should block port 8080 or disable the http interface manually (comment out line 7, 8 in ts3http.y).
  • Loading branch information
derkalle4 committed Jun 7, 2015
1 parent 2acff31 commit 12c7306
Show file tree
Hide file tree
Showing 38 changed files with 38,353 additions and 7 deletions.
15 changes: 8 additions & 7 deletions ts3eventscripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,23 @@
import time
import configparser
from ts3base import ts3base
from ts3http import ts3http
from threading import Thread
from myexception import MyException

config = configparser.ConfigParser()
config.read('config.ini')

# start ts3 instances
for key in config:
if key.startswith('instance'):
ts3 = ts3base({'id': config[key]['id'],
'ip': config[key]['ip'],
'port': int(config[key]['port']),
'sid': int(config[key]['sid']),
'user': config[key]['user'],
'pass': config[key]['pass'],
'name': config[key]['name'], })
ts3 = ts3base(config[key])
ts3.daemon = True
ts3.start()
# start webinterface
t = Thread(target=ts3http, args=())
t.daemon = True
t.start()

try:
while 1:
Expand Down
51 changes: 51 additions & 0 deletions ts3http.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import os
from http.server import HTTPServer, CGIHTTPRequestHandler


class ts3http():
def __init__(self):
serv = HTTPServer(('', 8080), MyRequestHandler)
serv.serve_forever()

class MyRequestHandler(CGIHTTPRequestHandler):
def do_GET(self):
path = './wwwroot/' + self.path.split('?')[0]
if self.path == "/":
self.send_response(200)
self.send_header("Content-type", "text/html")
self.end_headers()
f = open('./wwwroot/index.html')
self.wfile.write(bytes(f.read(), 'UTF-8'))
f.close()
elif '.html' in path:
self.send_response(200)
self.send_header("Content-type", "text/html")
self.end_headers()
f = open(path)
self.wfile.write(bytes(f.read(), 'UTF-8'))
f.close()
return
else:
try:
if '/assets/' in self.path:
fileName, fileExtension = os.path.splitext(path)
f = open(path, 'rb')
if fileExtension == '.png':
contentType = 'image/png'
elif fileExtension == '.jpg' or fileExtension == '.jpeg':
contentType = 'image/jpeg'
elif fileExtension == '.css':
contentType = 'text/css'
else:
contentType = 'text/html'
self.send_response(200)
self.send_header('Content-type', contentType)
self.end_headers()
self.wfile.write(f.read())
f.close()
return
except IOError:
self.send_error(404, 'file not found: %s' % self.path)

def do_POST(self):
self.do_GET()
Loading

0 comments on commit 12c7306

Please sign in to comment.