Mercurial > code > home > repos > video
diff video.py @ 0:3f2da406c788
start
author | drewp@bigasterisk.com |
---|---|
date | Tue, 21 Jul 2020 23:28:04 -0700 |
parents | |
children | ee55ed10faec |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/video.py Tue Jul 21 23:28:04 2020 -0700 @@ -0,0 +1,61 @@ +import docopt + +from twisted.internet import reactor +import cyclone.httpserver +import cyclone.web +import requests + +from cycloneerr import PrettyErrorHandler +from patchablegraph import PatchableGraph, CycloneGraphEventsHandler, CycloneGraphHandler +from standardservice.logsetup import log, verboseLogging + + +def getLoginBar(request: cyclone.httpserver.HTTPRequest): + c = requests.get('http://bang:9023/_loginBar', + headers={'Cookie': request.headers['cookie']}) + return c.content + + +class Transaction(PrettyErrorHandler, cyclone.web.RequestHandler): + def get(self): + self.render('transaction.html', + txn='data', + loginBar=getLoginBar(self.request)) + + +def main(): + args = docopt.docopt(''' +Usage: + video.py [options] + +Options: + -v, --verbose more logging +''') + verboseLogging(args['--verbose']) + + graph = PatchableGraph() + + class Application(cyclone.web.Application): + def __init__(self): + handlers = [ + (r"/()", cyclone.web.StaticFileHandler, {'path': '.', 'default_filename': 'index.html'}), + (r'/build/(bundle\.js)', cyclone.web.StaticFileHandler, {'path': './build/'}), + (r'/shaka-player/dist/(.*)', cyclone.web.StaticFileHandler, {'path': './shaka-player/dist/'}), + (r'/transaction', Transaction), + (r'/graph/video', CycloneGraphHandler, {'masterGraph': graph}), + (r'/graph/video/events', CycloneGraphEventsHandler, {'masterGraph': graph}), + ] + cyclone.web.Application.__init__( + self, + handlers, + graph=graph, + debug=args['--verbose'], + template_path='.', + ) + + reactor.listenTCP(9053, Application(), interface='::') + reactor.run() + + +if __name__ == '__main__': + main()