distil/bin/web.py
adriant fcfa0f077d Renaming Artifice to Distil
Lots of general rename changes, and a few pieces of minor tidy up.

Change-Id: Ia88b75af0e2d294cfc57164ac42155234d8ba71a
2014-06-12 13:19:29 +12:00

27 lines
674 B
Python

#!/usr/bin/python
from distil.api import web
import yaml
import sys
import argparse
a = argparse.ArgumentParser("Web service for Distil")
a.add_argument("-c", "--config", dest="config", help="Path to config file", default="/etc/distil/conf.yaml")
a.add_argument("-i", "--interface", dest="ip", help="IP address to serve on.", default="0.0.0.0")
a.add_argument("-p", "--port", help="port to serve on", default="8000")
args = a.parse_args()
conf = None
try:
with open(args.config) as f:
conf = yaml.load(f)
except IOError as e:
print "Couldn't load config file: %s" % e
sys.exit(1)
app = web.get_app(conf)
app.run(host=args.ip, port=int(args.port))