Spaces:
Sleeping
Sleeping
jayanth922 commited on
Commit ·
fcc2e99
1
Parent(s): e201c1c
autoload DEFAULT_PROFILE on Spaces
Browse files
app.py
CHANGED
|
@@ -33,6 +33,21 @@ def main():
|
|
| 33 |
args = parser.parse_args()
|
| 34 |
|
| 35 |
spec, base_url, bearer = args.spec, args.base_url, args.bearer
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
if args.profile:
|
| 37 |
p_spec, p_base, p_bearer = _load_profile(args.profile)
|
| 38 |
# CLI flags take precedence if provided, else use profile values
|
|
|
|
| 33 |
args = parser.parse_args()
|
| 34 |
|
| 35 |
spec, base_url, bearer = args.spec, args.base_url, args.bearer
|
| 36 |
+
|
| 37 |
+
# If running in Spaces (no CLI flags), autoload a profile.
|
| 38 |
+
if not (spec or args.profile):
|
| 39 |
+
default_profile = os.getenv("DEFAULT_PROFILE", "httpbin")
|
| 40 |
+
try:
|
| 41 |
+
p_spec, p_base, p_bearer = _load_profile(default_profile)
|
| 42 |
+
spec = p_spec
|
| 43 |
+
base_url = base_url or p_base
|
| 44 |
+
# only take bearer from profile if user didn't pass one
|
| 45 |
+
bearer = bearer if (bearer is not None and bearer != "") else (p_bearer or None)
|
| 46 |
+
args.profile = default_profile
|
| 47 |
+
print(f"[Space] No flags; auto-loading profile '{default_profile}'")
|
| 48 |
+
except Exception as e:
|
| 49 |
+
print(f"[Space] Could not autoload profile '{default_profile}': {e}")
|
| 50 |
+
|
| 51 |
if args.profile:
|
| 52 |
p_spec, p_base, p_bearer = _load_profile(args.profile)
|
| 53 |
# CLI flags take precedence if provided, else use profile values
|