Skip to content

Commit

Permalink
add headers to requests (#213)
Browse files Browse the repository at this point in the history
* feat: add custom User-Agent header for requests in streamlit_app.py

* feat: add headers to requests in download function of streamlit_app.py
  • Loading branch information
vasiliadi authored Feb 13, 2025
1 parent e007a2f commit da23022
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/streamlit_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@
INCREDIBLY_FAST_WHISPER = "vaibhavs10/incredibly-fast-whisper"
WHISPER = "openai/whisper"

# Headers for requests https://www.whatismybrowser.com/guides/the-latest-user-agent/chrome
headers = {
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36",
}

# Initialization
if "mode" not in st.session_state:
Expand Down Expand Up @@ -96,13 +100,15 @@ def download(url, mode=st.session_state.mode):
url = BeautifulSoup(
requests.get(
requests.utils.requote_uri(url),
headers=headers,
verify=True,
timeout=120,
).content,
"html.parser",
).source.get("src")
downloaded_file = requests.get(
requests.utils.requote_uri(url),
headers=headers,
verify=True,
timeout=120,
)
Expand Down

0 comments on commit da23022

Please sign in to comment.