MCPcopy
hub / github.com/aio-libs/aiohttp / init

Function init

examples/cli_app.py:25–54  ·  view source on GitHub ↗
(argv)

Source from the content-addressed store, hash-verified

23
24
25def init(argv):
26 arg_parser = ArgumentParser(
27 prog="aiohttp.web ...", description="Application CLI", add_help=False
28 )
29
30 # Positional argument
31 arg_parser.add_argument(
32 "message",
33 help="message to print"
34 )
35
36 # Optional argument
37 arg_parser.add_argument(
38 "--repeat",
39 help="number of times to repeat message", type=int, default="1"
40 )
41
42 # Avoid conflict with -h from `aiohttp.web` CLI parser
43 arg_parser.add_argument(
44 "--app-help",
45 help="show this message and exit", action="help"
46 )
47
48 args = arg_parser.parse_args(argv)
49
50 app = Application()
51 app["args"] = args
52 app.router.add_route('GET', '/', display_message)
53
54 return app

Callers

nothing calls this directly

Calls 2

ApplicationClass · 0.90
add_routeMethod · 0.45

Tested by

no test coverage detected