cdleong commited on
Commit
29ae2b4
1 Parent(s): 8329262

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -1,7 +1,9 @@
1
  import streamlit as st
2
  import langcodes
3
- from requests_html import HTMLSession
4
- session = HTMLSession()
 
 
5
 
6
  # https://huggingface.co/blog/streamlit-spaces
7
  langtext = st.text_input("language lookup using https://github.com/rspeer/langcodes, see also https://r12a.github.io/app-subtags/", "english")
@@ -37,8 +39,8 @@ if lang is None:
37
 
38
 
39
  r12_url = f"https://r12a.github.io/app-subtags/?find={langtext}"
40
- r = session.get(r12_url)
41
- r.html.render()
42
  st.write(r.html.search("language codes"))
43
 
44
  #st.write(f"langcodes found the following tag: {type(found)}") # a Language object
 
1
  import streamlit as st
2
  import langcodes
3
+ import asyncio
4
+ loop = asyncio.get_running_loop()
5
+ from requests_html import AsyncHTMLSession
6
+ asession = AsyncHTMLSession(loop=loop)
7
 
8
  # https://huggingface.co/blog/streamlit-spaces
9
  langtext = st.text_input("language lookup using https://github.com/rspeer/langcodes, see also https://r12a.github.io/app-subtags/", "english")
 
39
 
40
 
41
  r12_url = f"https://r12a.github.io/app-subtags/?find={langtext}"
42
+ r = await asession.get(r12_url)
43
+ r.html.arender()
44
  st.write(r.html.search("language codes"))
45
 
46
  #st.write(f"langcodes found the following tag: {type(found)}") # a Language object