Skip to content

Commit a14e549

Browse files
committed
tidied code
1 parent 87dd161 commit a14e549

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/cs50/flask.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,21 @@ def _wrap_flask(f):
1414

1515
f.logging.default_handler.formatter.formatException = lambda exc_info: _formatException(*exc_info)
1616

17-
if os.getenv("CS50_IDE_TYPE") == "online":
17+
if os.getenv("CS50_IDE_TYPE"):
1818
from werkzeug.middleware.proxy_fix import ProxyFix
1919
_flask_init_before = f.Flask.__init__
2020
def _flask_init_after(self, *args, **kwargs):
2121
_flask_init_before(self, *args, **kwargs)
22-
self.wsgi_app = ProxyFix(self.wsgi_app, x_proto=1)
22+
self.config["TEMPLATES_AUTO_RELOAD"] = True # Automatically reload templates
23+
self.wsgi_app = ProxyFix(self.wsgi_app, x_proto=1) # For HTTPS-to-HTTP proxy
2324
f.Flask.__init__ = _flask_init_after
2425

2526

26-
# Flask was imported before cs50
27+
# If Flask was imported before cs50
2728
if "flask" in sys.modules:
2829
_wrap_flask(sys.modules["flask"])
2930

30-
# Flask wasn't imported
31+
# If Flask wasn't imported
3132
else:
3233
flask_loader = pkgutil.get_loader('flask')
3334
if flask_loader:

src/cs50/sql.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -333,10 +333,9 @@ def shutdown_session(exception=None):
333333
# Execute statement
334334
if self._autocommit:
335335
connection.execute(sqlalchemy.text("BEGIN"))
336-
result = connection.execute(sqlalchemy.text(statement))
336+
result = connection.execute(sqlalchemy.text(statement))
337+
if self._autocommit:
337338
connection.execute(sqlalchemy.text("COMMIT"))
338-
else:
339-
result = connection.execute(sqlalchemy.text(statement))
340339

341340
# Check for end of transaction
342341
if command in ["COMMIT", "ROLLBACK"]:

0 commit comments

Comments
 (0)