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

Function hostname_set

app/api.py:482–501  ·  view source on GitHub ↗

Changes the machine’s hostname. Expects a JSON data structure in the request body that contains the new hostname as string. Example: { "hostname": "grandpilot" } Returns: Empty response on success, error object otherwise.

()

Source from the content-addressed store, hash-verified

480@api_blueprint.route('/hostname', methods=['PUT'])
481@required_auth(auth.Role.ADMIN)
482def hostname_set():
483 """Changes the machine’s hostname.
484
485 Expects a JSON data structure in the request body that contains the
486 new hostname as string. Example:
487 {
488 "hostname": "grandpilot"
489 }
490
491 Returns:
492 Empty response on success, error object otherwise.
493 """
494 try:
495 new_hostname = request_parsers.hostname.parse_hostname(flask.request)
496 hostname.change(new_hostname)
497 return json_response.success()
498 except request_parsers.errors.Error as e:
499 return json_response.error(e), 400
500 except hostname.Error as e:
501 return json_response.error(e), 500
502
503
504@api_blueprint.route('/network/status', methods=['GET'])

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected