MCPcopy Create free account
hub / github.com/tiny-pilot/tinypilot / settings_requires_https_put

Function settings_requires_https_put

app/api.py:672–696  ·  view source on GitHub ↗

Stores whether the server should require the client to connect via HTTPS. Expects a JSON data structure in the request body that contains the new setting `requiresHttps` as bool. Example: { "requiresHttps": true } Returns: Empty response on success, error object

()

Source from the content-addressed store, hash-verified

670@api_blueprint.route('/settings/requiresHttps', methods=['PUT'])
671@required_auth(auth.Role.ADMIN)
672def settings_requires_https_put():
673 """Stores whether the server should require the client to connect via HTTPS.
674
675 Expects a JSON data structure in the request body that contains the new
676 setting `requiresHttps` as bool. Example:
677 {
678 "requiresHttps": true
679 }
680
681 Returns:
682 Empty response on success, error object otherwise.
683 """
684 try:
685 should_be_required = request_parsers.requires_https.parse(flask.request)
686 except request_parsers.errors.Error as e:
687 return json_response.error(e), 400
688 db.settings.Settings().set_requires_https(should_be_required)
689
690 # Configure cookie security.
691 is_session_cookie_secure = (not flask.current_app.debug and
692 should_be_required)
693 flask.current_app.config.update(
694 SESSION_COOKIE_SECURE=is_session_cookie_secure)
695
696 return json_response.success()
697
698
699@api_blueprint.route('/settings/video', methods=['GET'])

Callers

nothing calls this directly

Calls 1

set_requires_httpsMethod · 0.80

Tested by

no test coverage detected