Ensure we increment and return the history_id when throwing error404() in website mode. Add a route for /favicon.ico unless we are in website mode (website might have its own favicon)

This commit is contained in:
Miguel Jacq 2019-09-09 17:22:18 +10:00
parent b1aa36e805
commit 86a2b35d9d
No known key found for this signature in database
GPG Key ID: EEA4341C6D97A0B6
2 changed files with 12 additions and 3 deletions

View File

@ -10,7 +10,7 @@ from distutils.version import LooseVersion as Version
from urllib.request import urlopen
import flask
from flask import Flask, request, render_template, abort, make_response, __version__ as flask_version
from flask import Flask, request, render_template, abort, make_response, send_file, __version__ as flask_version
from flask_httpauth import HTTPBasicAuth
from .. import strings
@ -178,6 +178,11 @@ class Web:
return ""
abort(404)
if self.mode != 'website':
@self.app.route("/favicon.ico")
def favicon():
return send_file('{}/img/favicon.ico'.format(self.common.get_resource_path('static')))
def error401(self):
auth = request.authorization
if auth:

View File

@ -70,7 +70,9 @@ class WebsiteModeWeb(SendBaseModeWeb):
# If it's not a directory or file, throw a 404
else:
return self.web.error404()
history_id = self.cur_history_id
self.cur_history_id += 1
return self.web.error404(history_id)
else:
# Special case loading /
@ -87,4 +89,6 @@ class WebsiteModeWeb(SendBaseModeWeb):
else:
# If the path isn't found, throw a 404
return self.web.error404()
history_id = self.cur_history_id
self.cur_history_id += 1
return self.web.error404(history_id)