From 767257db8d09031800b9c52e654162679dbb8b36 Mon Sep 17 00:00:00 2001 From: Eko Date: Fri, 10 Jul 2015 00:39:09 +0200 Subject: [PATCH] Added support for the hostname --- tesseractserver.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tesseractserver.py b/tesseractserver.py index bf45dc2..38f6892 100644 --- a/tesseractserver.py +++ b/tesseractserver.py @@ -141,6 +141,7 @@ def post(self): def main(): parser = optparse.OptionParser() + parser.add_option('-h', '--host', dest='host', help='the listening Hostname of RESTful tesseract web service. (default: all)') parser.add_option('-p', '--port', dest='port', help='the listening port of RESTful tesseract web service. (default: 1688)') parser.add_option('-l', '--lang', dest='lang', help='the targe language. (default: eng)') parser.add_option('-b', '--lib-path', dest='libPath', help='the absolute path of tesseract library.') @@ -167,12 +168,16 @@ def main(): wrapper = TesseactWrapper(lang, libpath, tessdata) port = options.port - if not options.port: # if port is not given, use the default one + if not options.port: # if port is not given, use the default one port = 1688 + host = options.host + if not options.host: # if port is not given, use the default one + host = '0.0.0.0' + http_server = tornado.httpserver.HTTPServer(application) - http_server.listen(port) - print "Tesseract Web Service starts at port " + str(port) + "." + http_server.listen(port,host) + print "Tesseract Web Service starts at " + str(host) + ":" + str(port) + "." tornado.ioloop.IOLoop.instance().start() if __name__ == "__main__":