Spaces:
Sleeping
Sleeping
Commit
·
1b04006
1
Parent(s):
aa65d00
Add Cloud Run PORT environment variable support
Browse files
app.py
CHANGED
|
@@ -924,9 +924,14 @@ _prefetch_from_env()
|
|
| 924 |
demo = build_ui()
|
| 925 |
|
| 926 |
if __name__ == "__main__": # pragma: no cover
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 927 |
demo.launch(
|
| 928 |
-
server_name=
|
| 929 |
-
server_port=
|
| 930 |
show_api=True
|
| 931 |
)
|
| 932 |
|
|
|
|
| 924 |
demo = build_ui()
|
| 925 |
|
| 926 |
if __name__ == "__main__": # pragma: no cover
|
| 927 |
+
# Support both Hugging Face Spaces and Google Cloud Run
|
| 928 |
+
# Cloud Run uses PORT, Hugging Face Spaces uses GRADIO_SERVER_PORT
|
| 929 |
+
port = int(os.environ.get("PORT", os.environ.get("GRADIO_SERVER_PORT", 7860)))
|
| 930 |
+
server_name = os.environ.get("GRADIO_SERVER_NAME", "0.0.0.0")
|
| 931 |
+
|
| 932 |
demo.launch(
|
| 933 |
+
server_name=server_name,
|
| 934 |
+
server_port=port,
|
| 935 |
show_api=True
|
| 936 |
)
|
| 937 |
|