', "##QUERYPARAMS##", query)
return s
if video_app:
s = string_to_string_replace_attribute('', "##QUERYPARAMS##", query)
return s
url = get_clean_param(query, "file", "")
w = get_clean_param(query, "width", "")
h = get_clean_param(query, "height", "")
if w: w = 'width="' + w + '" '
if h: h = 'height="' + h + '" '
if iframe:
return ''
# result = ''
result = ''
return result
class TIMServer(http.server.BaseHTTPRequestHandler):
def do_OPTIONS(self):
self.send_response(200, "ok")
self.send_header('Access-Control-Allow-Origin', '*')
self.send_header('Access-Control-Allow-Methods', 'GET, POST, OPTIONS')
self.send_header("Access-Control-Allow-Headers", "X-Requested-With, Content-Type")
print(self.path)
print(self.headers)
def do_GET(self):
self.do_all(get_params(self))
def do_POST(self):
if self.path.find('/multihtml') < 0:
self.do_all(post_params(self))
return
print("do_POST MULTIHML ==========================================")
querys = multi_post_params(self)
do_headers(self, "application/json")
htmls = []
for query in querys:
usercode = get_json_param(query.jso, "state", "usercode", None)
if usercode: query.query["usercode"] = [usercode]
ttype = get_param(query, "type", "console").lower()
s = get_html(self, query, True)
# print(s)
htmls.append(s)
sresult = json.dumps(htmls)
self.wout(sresult)
def do_PUT(self):
self.do_all(post_params(self))
def wout(self, s):
self.wfile.write(s.encode("UTF-8"))
def do_all(self, query):
# print(self.path)
# print(self.headers)
# print query
show_html = self.path.find('/html') >= 0
is_css = self.path.find('/css') >= 0
is_js = self.path.find('/js') >= 0
is_reqs = self.path.find('/reqs') >= 0
is_video_reqs = self.path.find('/video/reqs') >= 0
content_type = 'text/plain'
if is_reqs: content_type = "application/json"
if show_html: content_type = 'text/html; charset=utf-8'
if is_css: content_type = 'text/css'
if is_js: content_type = 'application/javascript'
do_headers(self,content_type)
if self.path.find("refresh") >= 0:
self.wout(get_chache_keys())
clear_cache()
return
result_json = {"multihtml": True}
if is_video_reqs:
result_json = {"multihtml": True, "js": ["/svn/video/js/video.js"], "angularModule": ["videoApp"]}
if is_reqs:
result_str = json.dumps(result_json)
self.wout(result_str)
return
if is_css:
# printFileTo('cs.css',self.wfile)
return
if is_js:
# print(content_type)
self.wout(file_to_string('js/video.js'))
return
s = get_html(self, query, show_html)
self.wout(s)
return
def get_html(self, query, show_html):
is_image = self.path.find('/image/') >= 0
is_video = self.path.find('/video/') >= 0
if is_image:
s = get_image_html(query)
return s
if is_video:
s = get_video_html(query)
return s
# Was none of special, so print the file(s) in query
cla = get_param(query, "class", "")
w = get_param(query, "width", "")
if w: w = ' style="width:' + w + '"'
if cla: cla = " " + cla
s = ""
ffn = get_param(query,"file","")
fn = ffn
i = ffn.rfind("/")
if i >= 0: fn = ffn[i+1:]
if show_html: s += ''
s += get_file_to_output(query, show_html)
if show_html: s += '
'+fn+''
s = get_surrounding_headers(query, s)
return s
def keep_running():
return True
run_while_true(handler_class=TIMServer)