@ -1,7 +1,8 @@
#!/usr/bin/env python3.8
#!/usr/bin/env python3.8
import argparse
from flask import Flask , render_template , request
from flask import Flask , render_template , request
from onnx_modifier import onnxModifier
from onnx_modifier import onnxModifier
app = Flask ( __name__ )
app = Flask ( __name__ )
@app.route ( ' / ' )
@app.route ( ' / ' )
@ -18,12 +19,10 @@ def open_model():
return ' OK ' , 200
return ' OK ' , 200
@app.route ( ' /download ' , methods = [ ' POST ' ] )
@app.route ( ' /download ' , methods = [ ' POST ' ] )
def modify_and_download_model ( ) :
def modify_and_download_model ( ) :
modify_info = request . get_json ( )
modify_info = request . get_json ( )
# print(modify_info)
# print(modify_info)
onnx_modifier . reload ( ) # allow downloading for multiple times
onnx_modifier . reload ( ) # allow downloading for multiple times
onnx_modifier . modify ( modify_info )
onnx_modifier . modify ( modify_info )
@ -31,6 +30,18 @@ def modify_and_download_model():
return ' OK ' , 200
return ' OK ' , 200
def parse_args ( ) :
parser = argparse . ArgumentParser ( )
parser . add_argument ( ' --host ' , type = str , default = ' 127.0.0.1 ' , help = ' the hostname to listen on. Set this to " 0.0.0.0 " to have the server available externally as well ' )
parser . add_argument ( ' --port ' , type = int , default = 5000 , help = ' the port of the webserver. Defaults to 5000. ' )
parser . add_argument ( ' --debug ' , type = bool , default = True , help = ' enable or disable debug mode. ' )
args = parser . parse_args ( )
return args
def main ( ) :
args = parse_args ( )
app . run ( host = args . host , port = args . port , debug = args . debug )
if __name__ == ' __main__ ' :
if __name__ == ' __main__ ' :
app . debug = True
main ( )
app . run ( host = " 0.0.0.0 " )