-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathserver
More file actions
executable file
·53 lines (41 loc) · 1.62 KB
/
server
File metadata and controls
executable file
·53 lines (41 loc) · 1.62 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
49
50
51
52
53
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import logging
import os
import argparse
#Parse command line arguments using argparse
parser = argparse.ArgumentParser()
parser.add_argument('-l', action='store', default='127.0.0.1', metavar='LISTEN_ADDRESS',
help='Address to listen on. Default is 127.0.0.1')
parser.add_argument('-p', action='store', type=int, default=5000, metavar="LISTEN_PORT",
help='Port to listen on. Default is 5000.')
parser.add_argument('-d', action='store_true', default=False,
help='Enable Flask debugging. Should not be used in production.')
args = parser.parse_args()
SERVER = args.l
PORT = args.p
DEBUG = args.d
LOG_LEVEL = logging.INFO
#-----------------------------------------------------------------------------
# Do not edit anything below this line.
#-----------------------------------------------------------------------------
try:
os.mkdir('log')
except OSError:
# Log directory already exists
pass
log_file = os.path.join('log', 'ptnotes.log')
logging.basicConfig(
level=LOG_LEVEL,
filename=log_file)
console = logging.StreamHandler()
console.setLevel(logging.ERROR)
formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s')
console.setFormatter(formatter)
logging.getLogger('').addHandler(console)
logging.info('Starting PTNotes server.')
print('Starting PTNotes server on {0}:{1}'.format(SERVER, PORT))
cert_file = os.path.join('config', 'cert.pem')
key_file = os.path.join('config', 'key.pem')
import ptn.webserver as server
server.app.run(host=SERVER, port=PORT, debug=DEBUG, ssl_context=(cert_file, key_file))