mirror of
https://github.com/onionshare/onionshare.git
synced 2024-12-27 16:29:41 -05:00
implemeted debug mode. fixes #50
This commit is contained in:
parent
9bf8814a92
commit
6503f2afa1
@ -98,7 +98,7 @@ def main():
|
|||||||
filename = args.filename
|
filename = args.filename
|
||||||
local_only = args.local_only
|
local_only = args.local_only
|
||||||
stay_open = bool(args.stay_open)
|
stay_open = bool(args.stay_open)
|
||||||
debug = args.debug
|
debug = bool(args.debug)
|
||||||
|
|
||||||
onionshare.set_stay_open(stay_open)
|
onionshare.set_stay_open(stay_open)
|
||||||
|
|
||||||
@ -126,14 +126,15 @@ def main():
|
|||||||
webapp.onionshare = onionshare
|
webapp.onionshare = onionshare
|
||||||
webapp.onionshare_port = onionshare_port
|
webapp.onionshare_port = onionshare_port
|
||||||
webapp.filename = filename
|
webapp.filename = filename
|
||||||
|
webapp.qtapp = app
|
||||||
|
webapp.clipboard = app.clipboard()
|
||||||
|
webapp.stay_open = stay_open
|
||||||
if not local_only:
|
if not local_only:
|
||||||
webapp.onion_host = onion_host
|
webapp.onion_host = onion_host
|
||||||
else:
|
else:
|
||||||
webapp.onion_host = local_host
|
webapp.onion_host = local_host
|
||||||
webapp.qtapp = app
|
if debug:
|
||||||
webapp.clipboard = app.clipboard()
|
webapp.debug_mode()
|
||||||
webapp.stay_open = stay_open
|
|
||||||
webapp.debug = debug
|
|
||||||
|
|
||||||
# run the web app in a new thread
|
# run the web app in a new thread
|
||||||
webapp_port = onionshare.choose_port()
|
webapp_port = onionshare.choose_port()
|
||||||
|
@ -8,28 +8,23 @@ onion_host = None
|
|||||||
qtapp = None
|
qtapp = None
|
||||||
clipboard = None
|
clipboard = None
|
||||||
stay_open = None
|
stay_open = None
|
||||||
debug = None
|
|
||||||
|
|
||||||
url = None
|
url = None
|
||||||
|
|
||||||
# figure out this platform's temp dir
|
|
||||||
if platform.system() == 'Windows':
|
|
||||||
temp_dir = os.environ['Temp'].replace('\\', '/')
|
|
||||||
else:
|
|
||||||
temp_dir = '/tmp/'
|
|
||||||
|
|
||||||
# suppress output in windows
|
|
||||||
if platform.system() == 'Windows':
|
|
||||||
sys.stdout = open('{0}/onionshare.stdout.log'.format(temp_dir), 'w')
|
|
||||||
sys.stderr = open('{0}/onionshare.stderr.log'.format(temp_dir), 'w')
|
|
||||||
|
|
||||||
# log web errors to file
|
|
||||||
import logging
|
|
||||||
log_handler = logging.FileHandler('{0}/onionshare.web.log'.format(temp_dir))
|
|
||||||
log_handler.setLevel(logging.WARNING)
|
|
||||||
|
|
||||||
app = Flask(__name__, template_folder='./templates')
|
app = Flask(__name__, template_folder='./templates')
|
||||||
app.logger.addHandler(log_handler)
|
|
||||||
|
def debug_mode():
|
||||||
|
import logging
|
||||||
|
global app
|
||||||
|
|
||||||
|
if platform.system() == 'Windows':
|
||||||
|
temp_dir = os.environ['Temp'].replace('\\', '/')
|
||||||
|
else:
|
||||||
|
temp_dir = '/tmp/'
|
||||||
|
|
||||||
|
log_handler = logging.FileHandler('{0}/onionshare.web.log'.format(temp_dir))
|
||||||
|
log_handler.setLevel(logging.WARNING)
|
||||||
|
app.logger.addHandler(log_handler)
|
||||||
|
|
||||||
@app.route("/")
|
@app.route("/")
|
||||||
def index():
|
def index():
|
||||||
|
Loading…
Reference in New Issue
Block a user