mirror of
https://github.com/NousResearch/atropos.git
synced 2026-04-19 12:57:58 +00:00
Refactor API server initialization to accept command-line arguments, and default reload to False
This commit is contained in:
parent
4f0c464382
commit
96a3476bec
1 changed files with 21 additions and 3 deletions
|
|
@ -1,9 +1,27 @@
|
|||
"""
|
||||
Run the Trajectory API server.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
|
||||
import uvicorn
|
||||
|
||||
|
||||
def main():
|
||||
uvicorn.run("atroposlib.api:app", host="0.0.0.0", port=8000, reload=True)
|
||||
def main(host: str, port: int, reload: bool):
|
||||
"""
|
||||
Run the API server.
|
||||
Args:
|
||||
host: The host to run the API server on.
|
||||
port: The port to run the API server on.
|
||||
reload: Whether to reload the API server on code changes.
|
||||
"""
|
||||
uvicorn.run("atroposlib.api:app", host=host, port=port, reload=reload)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--host", type=str, default="0.0.0.0")
|
||||
parser.add_argument("--port", type=int, default=8000)
|
||||
parser.add_argument("--reload", type=bool, default=False)
|
||||
args = parser.parse_args()
|
||||
main(args.host, args.port, args.reload)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue