-
Notifications
You must be signed in to change notification settings - Fork 16
/
runserver.py
executable file
·54 lines (40 loc) · 1.43 KB
/
runserver.py
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
#!flask/bin/python
# -*- coding: utf-8 -*-
## Versao 0.1
## http://blog.perplexedlabs.com/2010/07/01/pythons-tornado-has-swept-me-off-my-feet/
import os, sys
import logging
import argparse
import signal
signal.signal(signal.SIGINT, signal.SIG_DFL)
from app import app
## Clean .pyc
os.system("find . -type f -iname *.pyc -exec rm -f {} \;")
os.system("echo 1 > http.log")
def flask_http(debug=False, ssl=False):
if (ssl):
from OpenSSL import SSL
context = SSL.Context(SSL.SSLv23_METHOD)
context.use_privatekey_file('ssl/server.key')
context.use_certificate_file('ssl/server.crt')
app.run(host='0.0.0.0', port=8010, debug=debug, ssl_context=context)
else:
app.run(host='0.0.0.0', port=8010, debug=debug)
def main():
#----------------------------------------
# parse arguments
#----------------------------------------
parser = argparse.ArgumentParser(description='Start SMB4Manager')
parser.add_argument('--flask', action='store_true')
parser.add_argument('--ssl', action='store_true')
parser.add_argument('--debug', action='store_true')
args = parser.parse_args()
#----------------------------------------
# create app files
#----------------------------------------
if args.flask:
flask_http(debug=args.debug, ssl=args.ssl)
sys.exit(1)
flask_http(debug=args.debug, ssl=args.ssl)
if __name__ == "__main__":
main()