Skip to content

Commit

Permalink
Change app.py
Browse files Browse the repository at this point in the history
  • Loading branch information
TomacGG committed Sep 10, 2024
1 parent d781f83 commit a6aede7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions content/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
db.row_factory = sqlite3.Row

# Log all requests for analytics purposes
log_file = open('access.log', 'a', buffering=1)
@app.before_request
def log_request():
log_file.write(f"{request.method} {request.path} {dict(request.form) if request.form else ''}\n")
with open('access.log', 'a', buffering=1) as log_file:
log_file.write(f"{request.method} {request.path} {dict(request.form) if request.form else ''}\n")


# Set user_id on request if user is logged in, or else set it to None.
@app.before_request
Expand All @@ -33,7 +34,6 @@ def check_authentication():
@app.route("/")
def index():
quotes = db.execute("select id, text, attribution from quotes order by id").fetchall()

return Response(quotes, request.user_id, request.args.get('error'))


Expand Down Expand Up @@ -106,7 +106,7 @@ def signin():
user_id = cursor.lastrowid

response = make_response(redirect('/'))
response.set_cookie('user_id', str(user_id))
response.set_cookie('user_id', str(user_id), secure=True, httponly=True, samesite='Lax')
return response


Expand Down

0 comments on commit a6aede7

Please sign in to comment.