Skip to content

Commit

Permalink
httptest-cache: Enable passing port and address to bind to
Browse files Browse the repository at this point in the history
  • Loading branch information
pdxjohnny committed Oct 25, 2023
1 parent c8f1255 commit a0778ca
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion httptest/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,19 @@ def cache():
help='Directory to cache requests in',
default=os.path.join(os.path.expanduser('~'),
'.cache', 'httptest'))
parser.add_argument(
"--addr", help="Address to bind to (default 127.0.0.1)", default="127.0.0.1"
)
parser.add_argument(
"--port", help="Port to bind to (default random)", type=int, default=0
)

args = parser.parse_args()

@Server(CachingProxyHandler.to(args.upstream, state_dir=args.state_dir))
@Server(
CachingProxyHandler.to(args.upstream, state_dir=args.state_dir),
addr=(args.addr, args.port),
)
def waiter(ts):
print('Serving on http://%s:%d' % (ts.server_name, ts.server_port,))
while True:
Expand Down

0 comments on commit a0778ca

Please sign in to comment.