-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First commit for ts3http - a webinterface to manage all instances. Cu…
…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
Showing
38 changed files
with
38,353 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
Oops, something went wrong.