Download api/fields/api_based_extension_fields.py from Underground-Digital/Workflow-Engine: direct link, hf CLI and curl.
- Browser
- Download file 717 Bytes
-
https://huggingface.co/spaces/Underground-Digital/Workflow-Engine/resolve/main/api/fields/api_based_extension_fields.py
- Command line
-
hf download hf://spaces/Underground-Digital/Workflow-Engine/api/fields/api_based_extension_fields.py
-
curl -L -o api_based_extension_fields.py https://huggingface.co/spaces/Underground-Digital/Workflow-Engine/resolve/main/api/fields/api_based_extension_fields.py
717 Bytes
| from flask_restful import fields | |
| from libs.helper import TimestampField | |
| class HiddenAPIKey(fields.Raw): | |
| def output(self, key, obj): | |
| api_key = obj.api_key | |
| # If the length of the api_key is less than 8 characters, show the first and last characters | |
| if len(api_key) <= 8: | |
| return api_key[0] + "******" + api_key[-1] | |
| # If the api_key is greater than 8 characters, show the first three and the last three characters | |
| else: | |
| return api_key[:3] + "******" + api_key[-3:] | |
| api_based_extension_fields = { | |
| "id": fields.String, | |
| "name": fields.String, | |
| "api_endpoint": fields.String, | |
| "api_key": HiddenAPIKey, | |
| "created_at": TimestampField, | |
| } | |