-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathharpoon.py
64 lines (52 loc) · 1.8 KB
/
harpoon.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import os
import sys
import signal
import getopt
import hou
from flask import Flask, request
from lib import logo
from lib import api
app = Flask(__name__)
app.config['JSON_SORT_KEYS'] = False
@app.route("/api/hdalibrary", methods=['GET'])
def hdalibrary():
return api.hdalibrary(request)
@app.route("/api/hdaprocessor/<hda_name>", methods=['GET', 'POST'])
def hdaprocessor(hda_name):
return api.hdaprocessor(hda_name, request)
@app.route("/api/hiplibrary", methods=['GET'])
def hiplibrary():
return api.hiplibrary(request)
@app.route("/api/hipprocessor/<hip_name>", methods=['GET', 'POST'])
def hipprocessor(hip_name):
return api.hipprocessor(hip_name, request)
@app.route("/api/torlibrary", methods=['GET'])
def torlibrary():
return api.torlibrary(request)
@app.route("/api/torprocessor/<tor_file>", methods=['GET', 'POST'])
def torprocessor(tor_file):
return api.torprocessor(tor_file, request)
def print_help_info():
print("Usage: hython harpoon.py [-p port (default:80)]")
print("Options:")
print("-?,-h : this help")
print("-d : run in debug mode")
print("-p : specify server port")
# print("-s : specify static files directory")
def on_exit(signal, frame):
print('Bye!')
sys.exit(0)
if __name__ == '__main__':
port = 80
debug = False
opts, args = getopt.getopt(sys.argv[1:], "hdp:s:", ["port=", "help", "debug", "static"])
for opt, arg in opts:
if opt in ("-h", "--help", "-?"):
print_help_info()
sys.exit()
elif opt in ("-d", "--debug"):
debug = True
elif opt in ("-p", "--port"):
port = int(arg)
signal.signal(signal.SIGINT, on_exit)
app.run(host = "0.0.0.0", port = port, debug = debug)