head request

This commit is contained in:
Roy Olav Purser 2021-04-30 17:51:09 +02:00
parent 6650cd1818
commit 7374cfed9d
No known key found for this signature in database
GPG Key ID: 0BA77797F072BC52

View File

@ -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,6 +35,7 @@ class MainHandler(tornado.web.RequestHandler):
if resp is not None:
src = resp.url
except Exception as e:
if write:
self.write(e)
return
else:
@ -46,12 +47,18 @@ class MainHandler(tornado.web.RequestHandler):
endpoint = stream.url
break
except Exception as e:
if write:
self.write(str(e))
return
if endpoint is None:
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)