Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- server/app.py +11 -12
server/app.py
CHANGED
|
@@ -63,23 +63,22 @@ def main(host: str = "0.0.0.0", port: int = 8000):
|
|
| 63 |
uv run --project . server --port 8001
|
| 64 |
python -m token_optimiser.server.app
|
| 65 |
|
| 66 |
-
Args:
|
| 67 |
-
host: Host address to bind to (default: "0.0.0.0")
|
| 68 |
-
port: Port number to listen on (default: 8000)
|
| 69 |
-
|
| 70 |
For production deployments, consider using uvicorn directly with
|
| 71 |
multiple workers:
|
| 72 |
uvicorn token_optimiser.server.app:app --workers 4
|
| 73 |
"""
|
|
|
|
| 74 |
import uvicorn
|
| 75 |
|
| 76 |
-
|
| 77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
|
| 79 |
-
|
| 80 |
-
import argparse
|
| 81 |
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
args = parser.parse_args()
|
| 85 |
-
main(port=args.port)
|
|
|
|
| 63 |
uv run --project . server --port 8001
|
| 64 |
python -m token_optimiser.server.app
|
| 65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
For production deployments, consider using uvicorn directly with
|
| 67 |
multiple workers:
|
| 68 |
uvicorn token_optimiser.server.app:app --workers 4
|
| 69 |
"""
|
| 70 |
+
import argparse
|
| 71 |
import uvicorn
|
| 72 |
|
| 73 |
+
if host == "0.0.0.0" and port == 8000:
|
| 74 |
+
parser = argparse.ArgumentParser()
|
| 75 |
+
parser.add_argument("--host", type=str, default="0.0.0.0")
|
| 76 |
+
parser.add_argument("--port", type=int, default=8000)
|
| 77 |
+
args = parser.parse_args()
|
| 78 |
+
host = args.host
|
| 79 |
+
port = args.port
|
| 80 |
|
| 81 |
+
uvicorn.run(app, host=host, port=port)
|
|
|
|
| 82 |
|
| 83 |
+
if __name__ == "__main__":
|
| 84 |
+
main()
|
|
|
|
|
|