diff --git a/README.md b/README.md index d632ad0..3aa9122 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ When that's done, get `binhop` running with something like: git clone https://github.com/darrylnixon/binhop.git cd binhop pip install -r requirements.txt -./binhop.py +./binhop.py [--port ] ``` Once running, browse to [http://localhost:8080](http://localhost:8080) and upload a blob. diff --git a/binhop.py b/binhop.py index ccd6435..6480b27 100644 --- a/binhop.py +++ b/binhop.py @@ -9,6 +9,7 @@ import os from aiohttp_compress import compress_middleware from aiohttp import web from typing import List, Tuple, Dict, Union +import argparse async def scan_file(filename: str, base_dir: str) -> List: @@ -132,6 +133,10 @@ async def serve_static(request: web.Request) -> Union[web.FileResponse, web.HTTP async def main() -> None: + parser = argparse.ArgumentParser() + parser.add_argument("--port", "-p", type=int, default=8080, help="Port to serve on") + args = parser.parse_args() + app = web.Application() app.middlewares.append(compress_middleware) @@ -145,10 +150,10 @@ async def main() -> None: runner = web.AppRunner(app) await runner.setup() - site = web.TCPSite(runner, "localhost", 8080) + site = web.TCPSite(runner, "0.0.0.0", args.port) await site.start() - print("binhop is running at http://localhost:8080") + print(f"binhop is running at http://localhost:{args.port}") await asyncio.Event().wait()