Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable XSRF protection in StreamlitFrontend to support upload in localhost #15684

Merged
merged 9 commits into from
Nov 22, 2022
3 changes: 3 additions & 0 deletions src/lightning_app/frontend/stream_lit.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import lightning_app
from lightning_app.frontend.frontend import Frontend
from lightning_app.utilities.cloud import is_running_in_cloud
from lightning_app.utilities.imports import requires
from lightning_app.utilities.log import get_logfile

Expand Down Expand Up @@ -83,6 +84,8 @@ def start_server(self, host: str, port: int) -> None:
self.flow.name,
"--server.headless",
"true", # do not open the browser window when running locally
"--server.enableXsrfProtection",
"true" if is_running_in_cloud() else "false",
],
env=env,
stdout=stdout,
Expand Down
2 changes: 2 additions & 0 deletions tests/tests_app/frontend/test_stream_lit.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ def test_streamlit_frontend_start_stop_server(subprocess_mock):
"root.my.flow",
"--server.headless",
"true",
"--server.enableXsrfProtection",
"false",
]

assert env_variables["LIGHTNING_FLOW_NAME"] == "root.my.flow"
Expand Down