-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
executable file
·44 lines (33 loc) · 1.18 KB
/
server.py
File metadata and controls
executable file
·44 lines (33 loc) · 1.18 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
#!/usr/bin/python
# -*- coding: utf-8 -*-
__author__ = 'BernardoGO'
import config
from server.utils import info
from server.handlers.requestHandler import requestHandler
from server.support import multithreadSupport
from server.utils import statusCheck
from server.utils import checkFolders
from server.utils import parseArgs
import argparse
import sys
if sys.version_info >= (3, 0):
import http.server as http
else:
from BaseHTTPServer import HTTPServer as http
def main():
parseArgs.parseAll()
checkFolders.createIfNotExists()
if config.__ENABLE_MULTITHREADING__ == False:
server = http((config.__LISTEN_ADDRESS__, config.__INTERNAL_PORT__), requestHandler)
else:
server = multithreadSupport.ThreadedHTTPServer((config.__LISTEN_ADDRESS__, config.__INTERNAL_PORT__),
requestHandler)
statusCheck.printConfigs()
if parseArgs.parsed.ver == True:
print ("Server Version: "+str(info.__SRV_VERSION__))
return
if parseArgs.parsed.test == False:
print('Starting server, use <Ctrl-C> to stop\nStarted.')
server.serve_forever()
if __name__ == '__main__':
main()