Skip to content

Allow Streamlit server to handle Range Requests#1967

Merged
kmcgrady merged 8 commits intostreamlit:developfrom
kmcgrady:media-start-1804
Oct 8, 2020
Merged

Allow Streamlit server to handle Range Requests#1967
kmcgrady merged 8 commits intostreamlit:developfrom
kmcgrady:media-start-1804

Conversation

@kmcgrady
Copy link
Copy Markdown
Collaborator

@kmcgrady kmcgrady commented Sep 3, 2020

Issue: #1804 #1294

Description:

Browsers are beginning to require Range Requests (notably Chrome and Safari) in order to display/set the start time effectively. This change fixes adds that functionality.

The Range Request is managed will in Tornado's StaticFileHandler, so I subclassed it and followed their convention for using the MediaFileManager vs an actual path.

We also remove the 5 second timer in favor of expiring files after a script completes running or when the session is disconnected.


Contribution License Agreement

By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.

@kmcgrady kmcgrady marked this pull request as ready for review September 30, 2020 05:48
@kmcgrady kmcgrady requested a review from a team September 30, 2020 05:48
}

if (videoNode) {
videoNode.addEventListener("loadedmetadata", setStartTime)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is an use case we care about but it doesn't look like the metadata gets reloaded during reruns. Basically if you change the start_time in your script without doing a hard refresh, nothing happens.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed this. This is fine overall. I think changing start time around is a weird UX, and it will work if the src changes.

{"path": "%s/" % file_util.get_assets_dir()},
),
(make_url_path_regex(base, "media/(.*)"), MediaFileHandler),
(make_url_path_regex(base, "media/(.*)"), MediaFileHandler, {"path": ""}),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this? Not sure what the point of an empty string provides?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think Tornado sends the options as keyword arguments, so when it's missing the server errors out.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh is that because now it's a static file handler?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

@kmcgrady kmcgrady merged commit e8feac9 into streamlit:develop Oct 8, 2020
@kmcgrady kmcgrady deleted the media-start-1804 branch October 8, 2020 23:44
tconkling added a commit to tconkling/streamlit that referenced this pull request Oct 12, 2020
# By karrie (7) and others
# Via GitHub
* develop:
  Removing cache option from main menu if s4a (streamlit#2149)
  Fix empty deploy page (streamlit#2148)
  Don't wait for unit tests before starting Cypress (streamlit#2142)
  Fix formatting of st.file_uploader docstring (streamlit#2141)
  Fix broken link in 0.68 changelog (streamlit#2144)
  Fix useEffect warning (streamlit#2137)
  Add global GTM container (streamlit#2128)
  Allow Streamlit server to handle Range Requests (streamlit#1967)
  rename hosted to hostedAt (streamlit#2132)
  Update change log
  Update notices
  Up version to 0.68.0
  Rename hosted to hostedAt in tracking data (streamlit#2132)
  Inject tracking data (streamlit#2110)
  [Feature Branch] File uploader (streamlit#2130)
  links for docs (streamlit#2129)
  Upgrade ProtobufJS and fix build script (streamlit#2118)
  Refresh landing page (streamlit#2116)
  Improve docstrings + tutorials for Layout (streamlit#2117)
  Better 'streamlit run' error message when no extension provided (streamlit#2115)

# Conflicts:
#	frontend/src/components/elements/Video/Video.tsx
#	frontend/src/components/widgets/FileUploader/FileUploader.test.tsx
#	frontend/src/components/widgets/FileUploader/FileUploader.tsx
#	frontend/src/lib/utils.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants