shadowsocks/tests/coverage_server.py

27 lines
886 B
Python
Raw Normal View History

2014-12-24 08:47:14 +00:00
#!/usr/bin/env python
2014-12-24 09:06:15 +00:00
if __name__ == '__main__':
import tornado.ioloop
import tornado.web
import urllib
2014-12-24 08:47:14 +00:00
2014-12-24 09:06:15 +00:00
class MainHandler(tornado.web.RequestHandler):
def get(self, project):
try:
with open('/tmp/%s-coverage' % project, 'rb') as f:
coverage = f.read().strip()
self.redirect(('https://img.shields.io/badge/'
2014-12-28 04:35:17 +00:00
'coverage-%s-brightgreen.svg'
'?style=flat') %
urllib.quote(coverage))
except IOError:
raise tornado.web.HTTPError(404)
2014-12-24 08:47:14 +00:00
2014-12-24 09:06:15 +00:00
application = tornado.web.Application([
2014-12-28 07:00:29 +00:00
(r"/([a-zA-Z0-9\-_]+)", MainHandler),
2014-12-24 09:06:15 +00:00
])
2014-12-24 08:47:14 +00:00
2014-12-24 09:06:15 +00:00
if __name__ == "__main__":
application.listen(8888, address='127.0.0.1')
tornado.ioloop.IOLoop.instance().start()