diff --git a/html/index.html b/html/index.html new file mode 100644 index 00000000..2762a95d --- /dev/null +++ b/html/index.html @@ -0,0 +1,9 @@ + +
+ + + + + + + diff --git a/html/test.js b/html/test.js new file mode 100644 index 00000000..3f47eacc --- /dev/null +++ b/html/test.js @@ -0,0 +1,5 @@ + +function message() +{ + document.write("External javascript test!") +} diff --git a/plugins/web_remote.py b/plugins/web_remote.py new file mode 100644 index 00000000..d7650c25 --- /dev/null +++ b/plugins/web_remote.py @@ -0,0 +1,60 @@ +# Bryan Schumaker (11/13/2010) + +import ocarina +from libsaria import threads + +path = ocarina.libsaria.path +exists = path.exists +join = path.join + +from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer + +html = join(path.cwd(), "html") +server = None + +types = {".html":"html", ".js":"javascript"} + +class HTTPRequest(BaseHTTPRequestHandler): + + def do_GET(self): + global html + if self.path == "" or self.path == "/": + self.path = "/index.html" + try: + fpath = html + self.path + print fpath + if not exists(fpath): + raise IOError + base, ext = path.splitext(fpath) + self.send_response(200) + self.send_header('Content-type', 'text/%s' % types[ext]) + self.end_headers() + f = open(fpath) + self.wfile.write(f.read()) + f.close() + except IOError: + self.send_error(404, 'File Not Found: %s' % self.path) + + def do_POST(self): + print self.path + print "Received a post request!" + + +def start_server(): + global server + server = HTTPServer(('', 4242), HTTPRequest) + server.serve_forever() + +def start(): + threads.background(start_server) + +def stop(): + server.shutdown() + +def check_version(): + if ocarina.__major__ != 4: + return False + if ocarina.__minor__ >= 1: + return True + return False +