Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: modules/adblockplus/files/mimeo.py

Issue 29586667: Make mimeo module only listen to localhost (Closed)
Left Patch Set: Created Oct. 23, 2017, 3:41 p.m.
Right Patch Set: Fixing typo Created Oct. 23, 2017, 3:54 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 #!/usr/bin/env python3 1 #!/usr/bin/env python3
2 2
3 import argparse 3 import argparse
4 import re 4 import re
5 import sys 5 import sys
6 import threading 6 import threading
7 import traceback 7 import traceback
8 8
9 from http.server import BaseHTTPRequestHandler, HTTPServer 9 from http.server import BaseHTTPRequestHandler, HTTPServer
10 from string import Template 10 from string import Template
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 default=8000, type=int, 65 default=8000, type=int,
66 nargs='?', 66 nargs='?',
67 help='Port to use [default: 8000]') 67 help='Port to use [default: 8000]')
68 parser.add_argument('--response', action='store', 68 parser.add_argument('--response', action='store',
69 type=str, nargs='?', default='OK', 69 type=str, nargs='?', default='OK',
70 help='The response send to the client') 70 help='The response send to the client')
71 parser.add_argument('--format', action='store', 71 parser.add_argument('--format', action='store',
72 type=str, nargs='?', 72 type=str, nargs='?',
73 default=DEFAULT_LOG, 73 default=DEFAULT_LOG,
74 help='Format of the log ouput') 74 help='Format of the log ouput')
75 parser.add_argument('--address', action='store',
76 type=str, nargs='?',
77 default='127.0.0.1',
78 help='Address to listen on [default: 127.0.0.1]')
75 parser.add_argument('output', action='store', 79 parser.add_argument('output', action='store',
76 type=str, nargs='?', default='-', 80 type=str, nargs='?', default='-',
77 help='The file where the logs will be written') 81 help='The file where the logs will be written')
78 args = parser.parse_args() 82 args = parser.parse_args()
79 if args.output and args.output != '-': 83 if args.output and args.output != '-':
80 fh = open(args.output, 'a') 84 fh = open(args.output, 'a')
81 else: 85 else:
82 fh = open(sys.stdout.fileno(), 'w', closefd=False) 86 fh = open(sys.stdout.fileno(), 'w', closefd=False)
83 try: 87 try:
84 Handler.output = fh 88 Handler.output = fh
85 Handler.format = args.format 89 Handler.format = args.format
86 Handler.response = args.response 90 Handler.response = args.response
87 server_address = ('127.0.0.1', args.port) 91 server_address = (args.address, args.port)
88 httpd = HTTPServer(server_address, Handler) 92 httpd = HTTPServer(server_address, Handler)
89 httpd.serve_forever() 93 httpd.serve_forever()
90 finally: 94 finally:
91 fh.close() 95 fh.close()
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld