@@ -1326,19 +1326,7 @@ if __name__ == '__main__':
13261326 proxy.main()
13271327```
13281328
1329- Customize startup flags by passing list of input arguments:
1330-
1331- ``` python
1332- import proxy
1333-
1334- if __name__ == ' __main__' :
1335- proxy.main([
1336- ' --hostname' , ' ::1' ,
1337- ' --port' , ' 8899'
1338- ])
1339- ```
1340-
1341- or, customize startup flags by passing them as kwargs:
1329+ Customize startup flags by passing them as kwargs:
13421330
13431331``` python
13441332import ipaddress
@@ -1354,7 +1342,8 @@ if __name__ == '__main__':
13541342Note that:
13551343
135613441 . Calling ` main ` is simply equivalent to starting ` proxy.py ` from command line.
1357- 2 . ` main ` will block until ` proxy.py ` shuts down.
1345+ 2 . ` main ` doesn't accept any ` *args ` . It will automatically parse any available ` sys.argv ` .
1346+ 3 . ` main ` will block until ` proxy.py ` shuts down.
13581347
13591348## Non-blocking Mode
13601349
@@ -1365,7 +1354,7 @@ by using `Proxy` context manager: Example:
13651354import proxy
13661355
13671356if __name__ == ' __main__' :
1368- with proxy.Proxy([] ) as p:
1357+ with proxy.Proxy() as p:
13691358 # ... your logic here ...
13701359```
13711360
@@ -1375,8 +1364,8 @@ Note that:
137513642 . Internally ` Proxy ` is a context manager.
137613653 . It will start ` proxy.py ` when called and will shut it down
13771366 once the scope ends.
1378- 4 . Just like ` main ` , startup flags with ` Proxy `
1379- can be customized by either passing flags as list of
1367+ 4 . However, unlike ` main ` , startup flags with ` Proxy `
1368+ can also be customized by either passing flags as list of
13801369 input arguments e.g. ` Proxy(['--port', '8899']) ` or
13811370 by using passing flags as kwargs e.g. ` Proxy(port=8899) ` .
13821371
@@ -1390,7 +1379,7 @@ In embedded mode, you can access this port. Example:
13901379import proxy
13911380
13921381if __name__ == ' __main__' :
1393- with proxy.Proxy([] ) as p:
1382+ with proxy.Proxy() as p:
13941383 print (p.flags.port)
13951384```
13961385
@@ -1412,9 +1401,7 @@ Example, load a single plugin using `--plugins` flag:
14121401import proxy
14131402
14141403if __name__ == ' __main__' :
1415- proxy.main([
1416- ' --plugins' , ' proxy.plugin.CacheResponsesPlugin' ,
1417- ])
1404+ proxy.main(plugins = [' proxy.plugin.CacheResponsesPlugin' ])
14181405```
14191406
14201407For simplicity, you can also pass the list of plugins as a keyword argument to ` proxy.main ` or the ` Proxy ` constructor.
@@ -1426,7 +1413,7 @@ import proxy
14261413from proxy.plugin import FilterByUpstreamHostPlugin
14271414
14281415if __name__ == ' __main__' :
1429- proxy.main([], plugins = [
1416+ proxy.main(plugins = [
14301417 b ' proxy.plugin.CacheResponsesPlugin' ,
14311418 FilterByUpstreamHostPlugin,
14321419 ])
@@ -1436,8 +1423,7 @@ if __name__ == '__main__':
14361423
14371424## ` proxy.TestCase `
14381425
1439- To setup and tear down ` proxy.py ` for your Python ` unittest ` classes,
1440- simply use ` proxy.TestCase ` instead of ` unittest.TestCase ` .
1426+ To setup and tear down ` proxy.py ` for your Python ` unittest ` classes, simply use ` proxy.TestCase ` instead of ` unittest.TestCase ` .
14411427Example:
14421428
14431429``` python
0 commit comments