Skip to content
Snippets Groups Projects
Commit 0a8de9c8 authored by Christopher Randolph Rhodes's avatar Christopher Randolph Rhodes
Browse files

Merged in server script and API

parent e6ba8694
No related branches found
No related tags found
No related merge requests found
File moved
import uvicorn
host = '127.0.0.1'
port = 8001
if __name__ == '__main__':
uvicorn.run('api:app', **{'host': host, 'port': port, 'log_level': 'debug'}, reload=False)
\ No newline at end of file
import argparse
from multiprocessing import Process
import uvicorn
def parse_args():
parser = argparse.ArgumentParser(
description='Start model server with optional arguments',
)
parser.add_argument(
'--host',
default='127.0.0.1',
help='bind socket to this host'
)
parser.add_argument(
'--port',
default='8000',
help='bind socket to this port, default=8000',
)
parser.add_argument(
'--debug',
action='store_true',
help='display extra information that is helpful for debugging'
)
return parser.parse_args()
if __name__ == '__main__':
args = parse_args()
print('CLI args:\n' + str(args))
server_process = Process(
target=uvicorn.run,
args=('model_server.api:app',),
kwargs={
'app_dir': '.',
'host': args.host,
'port': int(args.port),
'log_level': 'debug',
'reload': False
},
daemon=True,
)
server_process.start()
if args.debug:
print('Running in debug mode')
print('Type "STOP" to stop server')
input_str = ''
while input_str.upper() != 'STOP':
input_str = input()
print('Finished')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment