Flask Request Object - check if the request was made from a secure protocol
The Flask request object can be used to check that a request was made using a secure protocol via
request.is_secure
:
- HTTPS - HTTP Secure
- WSS - WebSockets over SSL/TLS
👇
from flask import request, current_app @journal_blueprint.route('/journal', methods=['GET']) def get_journal(): # Only support secure protocols (HTTPS or WSS) if request.is_secure: current_app.logger.info(f'Journal request using protocol: {request.scheme}') return '<p>Journal Entries</p>'