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