mirror of
https://github.com/onionshare/onionshare.git
synced 2025-06-07 06:13:03 -04:00
merging in relevant work from #59
This commit is contained in:
parent
756fc99d3c
commit
fc13ef5707
2 changed files with 14 additions and 4 deletions
|
@ -58,7 +58,7 @@ def human_readable_filesize(b):
|
||||||
|
|
||||||
@app.route("/{0}".format(slug))
|
@app.route("/{0}".format(slug))
|
||||||
def index():
|
def index():
|
||||||
global filename, filesize, filehash, slug, strings, REQUEST_LOAD
|
global filename, filesize, filehash, slug, strings, REQUEST_LOAD, onionshare_dir
|
||||||
add_request(REQUEST_LOAD, request.path)
|
add_request(REQUEST_LOAD, request.path)
|
||||||
return render_template_string(
|
return render_template_string(
|
||||||
open('{0}/index.html'.format(onionshare_dir)).read(),
|
open('{0}/index.html'.format(onionshare_dir)).read(),
|
||||||
|
@ -126,7 +126,7 @@ def download():
|
||||||
|
|
||||||
@app.errorhandler(404)
|
@app.errorhandler(404)
|
||||||
def page_not_found(e):
|
def page_not_found(e):
|
||||||
global REQUEST_OTHER
|
global REQUEST_OTHER, onionshare_dir
|
||||||
add_request(REQUEST_OTHER, request.path)
|
add_request(REQUEST_OTHER, request.path)
|
||||||
return render_template_string(open('{0}/404.html'.format(onionshare_dir)).read())
|
return render_template_string(open('{0}/404.html'.format(onionshare_dir)).read())
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,17 @@ import logging
|
||||||
log_handler = logging.FileHandler('{0}/onionshare.web.log'.format(temp_dir))
|
log_handler = logging.FileHandler('{0}/onionshare.web.log'.format(temp_dir))
|
||||||
log_handler.setLevel(logging.WARNING)
|
log_handler.setLevel(logging.WARNING)
|
||||||
|
|
||||||
app = Flask(__name__, template_folder='./templates')
|
template_folder = './templates'
|
||||||
|
if platform.system() == 'Windows':
|
||||||
|
# pyinstaller sets sys.frozen=1 on run
|
||||||
|
application_path = ""
|
||||||
|
if getattr(sys, "frozen", False):
|
||||||
|
application_path = os.path.dirname(sys.executable)
|
||||||
|
elif __file__:
|
||||||
|
application_path = os.path.dirname(__file__)
|
||||||
|
template_path = os.path.join(application_path, "templates")
|
||||||
|
|
||||||
|
app = Flask(__name__, template_folder=template_path)
|
||||||
app.logger.addHandler(log_handler)
|
app.logger.addHandler(log_handler)
|
||||||
|
|
||||||
@app.route("/")
|
@app.route("/")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue