Skip to content

Commit

Permalink
Merge pull request #86 from cs50/develop
Browse files Browse the repository at this point in the history
4.0.2
  • Loading branch information
Kareem Zidane authored Jul 10, 2019
2 parents bd3e62e + d0e18fb commit e31b2e7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
package_dir={"": "src"},
packages=["cs50"],
url="https://github.com/cs50/python-cs50",
version="4.0.1"
version="4.0.2"
)
16 changes: 8 additions & 8 deletions src/cs50/flask.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,28 @@
except ImportError:
pass
else:
_before = SQL.execute
def _after(*args, **kwargs):
_execute_before = SQL.execute
def _execute_after(*args, **kwargs):
disabled = logging.getLogger("cs50").disabled
if flask.current_app:
logging.getLogger("cs50").disabled = False
try:
return _before(*args, **kwargs)
return _execute_before(*args, **kwargs)
finally:
logging.getLogger("cs50").disabled = disabled
SQL.execute = _after
SQL.execute = _execute_after

# When behind CS50 IDE's proxy, ensure that flask.redirect doesn't redirect from HTTPS to HTTP
# https://werkzeug.palletsprojects.com/en/0.15.x/middleware/proxy_fix/#module-werkzeug.middleware.proxy_fix
if getenv("C9_HOSTNAME") and not getenv("IDE_OFFLINE"):
try:
import flask
from werkzeug.middleware.proxy_fix import ProxyFix
_before = flask.Flask.__init__
def _after(self, *args, **kwargs):
_before(self, *args, **kwargs)
_flask_init_before = flask.Flask.__init__
def _flask_init_after(self, *args, **kwargs):
_flask_init_before(self, *args, **kwargs)
self.wsgi_app = ProxyFix(self.wsgi_app, x_proto=1)
flask.Flask.__init__ = _after
flask.Flask.__init__ = _flask_init_after
except:
pass

Expand Down

0 comments on commit e31b2e7

Please sign in to comment.