head request
This commit is contained in:
parent
6650cd1818
commit
7374cfed9d
@ -24,7 +24,7 @@ for key in proxies:
|
|||||||
proxies[key].set_option("https-proxy", proxy)
|
proxies[key].set_option("https-proxy", proxy)
|
||||||
|
|
||||||
class MainHandler(tornado.web.RequestHandler):
|
class MainHandler(tornado.web.RequestHandler):
|
||||||
def get(self):
|
def handle_any(self, write):
|
||||||
provider = self.get_query_argument("provider", None)
|
provider = self.get_query_argument("provider", None)
|
||||||
endpoint = None
|
endpoint = None
|
||||||
if provider is not None and provider in providers.keys():
|
if provider is not None and provider in providers.keys():
|
||||||
@ -35,6 +35,7 @@ class MainHandler(tornado.web.RequestHandler):
|
|||||||
if resp is not None:
|
if resp is not None:
|
||||||
src = resp.url
|
src = resp.url
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
if write:
|
||||||
self.write(e)
|
self.write(e)
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
@ -46,12 +47,18 @@ class MainHandler(tornado.web.RequestHandler):
|
|||||||
endpoint = stream.url
|
endpoint = stream.url
|
||||||
break
|
break
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
if write:
|
||||||
self.write(str(e))
|
self.write(str(e))
|
||||||
return
|
return
|
||||||
if endpoint is None:
|
if endpoint is None:
|
||||||
|
if write:
|
||||||
self.write("stream not found")
|
self.write("stream not found")
|
||||||
else:
|
else:
|
||||||
self.redirect(endpoint, status=303)
|
self.redirect(endpoint, status=303)
|
||||||
|
def get(self):
|
||||||
|
self.handle_any(True)
|
||||||
|
def head(self):
|
||||||
|
self.handle_any(False)
|
||||||
try:
|
try:
|
||||||
app_web = tornado.web.Application([(tornado.routing.AnyMatches(), MainHandler)])
|
app_web = tornado.web.Application([(tornado.routing.AnyMatches(), MainHandler)])
|
||||||
app_web.listen(8080)
|
app_web.listen(8080)
|
||||||
|
Loading…
Reference in New Issue
Block a user