zhiminy's picture
Update app.py
801cd8b verified
import requests
import streamlit as st
@st.cache_data(ttl=3600) # Cache the data for 1 hour
def fetch_readme_content():
try:
url = "https://raw.githubusercontent.com/EthicalML/awesome-production-machine-learning/master/README.md"
response = requests.get(url, timeout=30)
response.raise_for_status() # Raises HTTPError for bad responses
return response.text
except requests.exceptions.RequestException as e:
st.error(f"Failed to fetch README.md content: {e}")
return ""
class SearchApplication:
def __init__(self):
self.title = "Production Machine Learning Search"
self.set_page_config()
st.header(self.title)
self.query = st.text_input("Search", value="")
st.caption(
"This search toolkit is a user-friendly platform that enables efficient exploration and filtering of the comprehensive [Awesome Production Machine Learning](https://github.com/EthicalML/awesome-production-machine-learning) list, which includes over 500 machine learning SDKs, making it an indispensable resource for researchers, developers, and enthusiasts in the field."
)
st.write("#")
self.show_search_results()
def set_page_config(self):
st.set_page_config(
page_title=self.title,
page_icon="😎",
layout="centered",
)
def show_search_results(self):
if self.query:
st.write("#")
readme_content = fetch_readme_content()
if readme_content:
search_results = []
lines = readme_content.split("\n")
for line in lines:
if self.query.lower() in line.lower():
search_results.append(line)
num_search_results = len(search_results)
st.write(f"A total of {num_search_results} matches found.")
if num_search_results > 0:
for result in search_results:
st.write(result)
else:
st.write("No matches found.")
if __name__ == "__main__":
SearchApplication()