AnnNaser commited on
Commit
08c63c2
·
verified ·
1 Parent(s): 6004b99

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -4
app.py CHANGED
@@ -1,6 +1,27 @@
1
  import streamlit as st
2
  import requests
3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  # Function to fetch books from Open Library API
5
  def fetch_books(subject, start_year, end_year):
6
  base_url = "https://openlibrary.org/search.json"
@@ -32,13 +53,13 @@ def main():
32
  st.write("Find books by subject and publication year range.")
33
 
34
  # User inputs
35
- subject = st.text_input("Enter a subject (e.g., Science, History):", "Science")
36
- start_year = st.number_input("Enter start year:", min_value=1800, max_value=2100, value=2000)
37
- end_year = st.number_input("Enter end year:", min_value=1800, max_value=2100, value=2020)
38
 
39
  if st.button("Search"):
40
  if not subject:
41
- st.error("Please enter a subject.")
42
  elif start_year > end_year:
43
  st.error("Start year must be less than or equal to end year.")
44
  else:
 
1
  import streamlit as st
2
  import requests
3
 
4
+ # Predefined list of top 100 topics
5
+ TOP_100_TOPICS = [
6
+ "Science", "History", "Philosophy", "Technology", "Art", "Mathematics", "Literature", "Psychology", "Sociology",
7
+ "Economics", "Education", "Business", "Health", "Religion", "Politics", "Law", "Engineering", "Physics",
8
+ "Chemistry", "Astronomy", "Geography", "Medicine", "Music", "Theology", "Anthropology", "Archaeology",
9
+ "Linguistics", "Architecture", "Astronomy", "Biology", "Geology", "Botany", "Zoology", "Microbiology",
10
+ "Cultural Studies", "Environmental Studies", "Agriculture", "Urban Studies", "Gender Studies", "Film Studies",
11
+ "Political Science", "Social Science", "Computer Science", "Artificial Intelligence", "Robotics", "Econometrics",
12
+ "Communication", "Public Policy", "International Relations", "Global Studies", "Cognitive Science", "Mathematical Physics",
13
+ "Public Health", "Neuroscience", "Genetics", "Quantum Mechanics", "Linguistic Anthropology", "Classical Studies",
14
+ "Business Management", "Marketing", "Tourism", "Fashion", "Sports Science", "Nutrition", "Forensic Science",
15
+ "Public Administration", "Climate Science", "Oceanography", "Agricultural Engineering", "Renewable Energy", "Industrial Design",
16
+ "Entrepreneurship", "Social Work", "Criminal Justice", "Architecture and Urban Planning", "Computer Networks", "Cybersecurity",
17
+ "Pharmacology", "Veterinary Science", "Sports Studies", "Ethics", "Law Enforcement", "Geophysics", "Paleontology",
18
+ "Education Technology", "Artificial Intelligence in Education", "Food Science", "Human Geography", "Social Media", "Climate Change",
19
+ "Humanitarian Studies", "Creative Writing", "Music Composition", "Geospatial Technology", "Leadership", "Data Science", "Software Engineering",
20
+ "Marine Biology", "Financial Engineering", "Digital Media", "Neuroeconomics", "Public Speaking", "Digital Marketing", "Organizational Behavior",
21
+ "Criminology", "Human Rights", "Energy Studies", "Supply Chain Management", "Risk Management", "AI Ethics", "Food Security", "Healthcare Management",
22
+ "Digital Transformation", "Sustainability", "Mental Health", "Cyber Law", "Civil Engineering", "Mechanical Engineering", "Electrical Engineering"
23
+ ]
24
+
25
  # Function to fetch books from Open Library API
26
  def fetch_books(subject, start_year, end_year):
27
  base_url = "https://openlibrary.org/search.json"
 
53
  st.write("Find books by subject and publication year range.")
54
 
55
  # User inputs
56
+ subject = st.selectbox("Select a subject from the list:", TOP_100_TOPICS)
57
+ start_year = st.number_input("Enter start year:", min_value=1700, max_value=2025, value=2000)
58
+ end_year = st.number_input("Enter end year:", min_value=1700, max_value=2025, value=2020)
59
 
60
  if st.button("Search"):
61
  if not subject:
62
+ st.error("Please select a subject.")
63
  elif start_year > end_year:
64
  st.error("Start year must be less than or equal to end year.")
65
  else: