Skip to content

Commit e43d33c

Browse files
committed
Add utils; is_hosted() needs to be inspected
1 parent d3b5c45 commit e43d33c

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

shiny/bookmark/_utils.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import os
2+
from typing import Any
3+
4+
import orjson
5+
6+
7+
def is_hosted() -> bool:
8+
# Can't look at SHINY_PORT, as we already set it in shiny/_main.py's `run_app()`
9+
10+
# TODO: Support shinyapps.io or use `SHINY_PORT` how R-shiny did
11+
12+
# Instead, looking for the presence of the environment variable that Connect sets
13+
# (*_Connect) or Shiny Server sets (SHINY_APP)
14+
for env_var in ("POSIT_CONNECT", "RSTUDIO_CONNECT", "SHINY_APP"):
15+
if env_var in os.environ:
16+
return True
17+
return False
18+
19+
20+
def to_json(x: Any) -> dict[str, Any]:
21+
return orjson.loads(orjson.dumps(x))

0 commit comments

Comments
 (0)