-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
48 lines (36 loc) · 1.7 KB
/
main.py
File metadata and controls
48 lines (36 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import argparse
from servers.HTTPFileBrowserServer import HTTPFileBrowserServer
def main(args):
# addr = "127.0.0.1"
# port = 25252
s = HTTPFileBrowserServer(args.address_filter,
int(args.port),
args.root_directory,
)
s.start(int(args.max_connections))
if __name__ == "__main__":
parser = argparse.ArgumentParser(
prog='python main.py',
description = 'This program is a simple socket-based web server that\
lists and serves files over the network.\n\
The server generates a simple HTML webpage on the given port with a\
file browsing system.\n\
Default port: 25252',
epilog=''
)
parser.add_argument("root_directory",
help='Root directory of the file server.')
parser.add_argument('-p', '--port',
help='Port to listen on. Defaults to 25252',
default='25252')
parser.add_argument('--address_filter',
help='Server will only accept connections from this address. \
If not specified, server will listen for connections from any address.',
default='')
parser.add_argument('--max_connections',
help="Maximum number of connections the server should listen for.\n\
After the maximum number is reached, the server closes.\n\
Leave blank or '-1' for unlimited connections",
default='-1')
args = parser.parse_args()
main(args)