mirror of
https://github.com/DarrylNixon/binhop
synced 2024-04-22 12:37:06 -07:00
Add argparse'd --port option, for Docker
This commit is contained in:
parent
feeebd8fe5
commit
fb002fcca2
2 changed files with 8 additions and 3 deletions
|
@ -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 <port, default: 8080>]
|
||||
```
|
||||
|
||||
Once running, browse to [http://localhost:8080](http://localhost:8080) and upload a blob.
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue