RubaAnam1 commited on
Commit
8d4c474
Β·
verified Β·
1 Parent(s): 9e1b2a5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -26
app.py CHANGED
@@ -36,7 +36,7 @@ def call_gemini(prompt, api_key):
36
  def get_species_links(species_name):
37
  links = []
38
 
39
- # GBIF
40
  gbif_url = f"https://api.gbif.org/v1/species/match?name={species_name}"
41
  r = requests.get(gbif_url).json()
42
 
@@ -46,8 +46,8 @@ def get_species_links(species_name):
46
  # Wikipedia
47
  links.append(f"https://en.wikipedia.org/wiki/{species_name.replace(' ', '_')}")
48
 
49
- # OpenAlex research
50
- links.append(f"https://api.openalex.org/works?search={species_name}&per_page=3")
51
 
52
  return links
53
 
@@ -58,7 +58,7 @@ def get_species_links(species_name):
58
 
59
  st.set_page_config(page_title="Biodiversity GIS Explorer", layout="wide")
60
  st.title("🌍 Biodiversity GIS Explorer")
61
- st.write("GBIF + Gemini AI + Scientific Links + GIS Insights")
62
 
63
  # =========================
64
  # INPUTS
@@ -114,9 +114,9 @@ Species Type: {species_type}
114
  Species List:
115
  {species_text}
116
 
117
- 1. Give a short biodiversity summary of this country.
118
- 2. Explain GIS mapping use cases for these species.
119
- 3. Give a beginner QGIS roadmap for biodiversity analysis.
120
  """
121
 
122
  if GEMINI_API_KEY:
@@ -128,10 +128,10 @@ Species List:
128
  st.write(ai_text)
129
 
130
  # =========================
131
- # RESEARCH LINKS
132
  # =========================
133
 
134
- st.subheader("πŸ“š Scientific Research Links")
135
 
136
  all_links_text = ""
137
 
@@ -146,10 +146,10 @@ Species List:
146
  all_links_text += f"\n{sp}:\n" + "\n".join(links) + "\n"
147
 
148
  # =========================
149
- # PDF EXPORT
150
- # =========================
151
 
152
- final_text = f"""
153
  BIODIVERSITY REPORT
154
 
155
  Country: {country}
@@ -165,20 +165,22 @@ RESEARCH LINKS:
165
  {all_links_text}
166
  """
167
 
168
- pdf = FPDF()
169
- pdf.add_page()
170
- pdf.set_font("Arial", size=12)
 
 
 
171
 
172
- for line in final_text.split("\n"):
173
- pdf.multi_cell(0, 10, line)
174
 
175
- pdf_file = "biodiversity_report.pdf"
176
- pdf.output(pdf_file)
177
 
178
- with open(pdf_file, "rb") as f:
179
- st.download_button(
180
- label="πŸ“„ Download PDF Report",
181
- data=f,
182
- file_name="biodiversity_report.pdf",
183
- mime="application/pdf"
184
- )
 
 
36
  def get_species_links(species_name):
37
  links = []
38
 
39
+ # GBIF official page
40
  gbif_url = f"https://api.gbif.org/v1/species/match?name={species_name}"
41
  r = requests.get(gbif_url).json()
42
 
 
46
  # Wikipedia
47
  links.append(f"https://en.wikipedia.org/wiki/{species_name.replace(' ', '_')}")
48
 
49
+ # Google Scholar (REAL research results)
50
+ links.append(f"https://scholar.google.com/scholar?q={species_name}")
51
 
52
  return links
53
 
 
58
 
59
  st.set_page_config(page_title="Biodiversity GIS Explorer", layout="wide")
60
  st.title("🌍 Biodiversity GIS Explorer")
61
+ st.write("GBIF + Gemini AI + Scientific Links + PDF Export")
62
 
63
  # =========================
64
  # INPUTS
 
114
  Species List:
115
  {species_text}
116
 
117
+ 1. Give a short biodiversity summary.
118
+ 2. Explain GIS mapping use cases.
119
+ 3. Give a beginner QGIS roadmap.
120
  """
121
 
122
  if GEMINI_API_KEY:
 
128
  st.write(ai_text)
129
 
130
  # =========================
131
+ # SCIENTIFIC LINKS
132
  # =========================
133
 
134
+ st.subheader("πŸ“š Research Links")
135
 
136
  all_links_text = ""
137
 
 
146
  all_links_text += f"\n{sp}:\n" + "\n".join(links) + "\n"
147
 
148
  # =========================
149
+ # PDF EXPORT
150
+ # =========================
151
 
152
+ final_text = f"""
153
  BIODIVERSITY REPORT
154
 
155
  Country: {country}
 
165
  {all_links_text}
166
  """
167
 
168
+ pdf = FPDF()
169
+ pdf.add_page()
170
+ pdf.set_font("Arial", size=12)
171
+
172
+ for line in final_text.split("\n"):
173
+ pdf.multi_cell(0, 10, line)
174
 
175
+ pdf_file = "biodiversity_report.pdf"
 
176
 
177
+ pdf.output(pdf_file)
 
178
 
179
+ with open(pdf_file, "rb") as f:
180
+ st.download_button(
181
+ label="πŸ“„ Download PDF Report",
182
+ data=f,
183
+ file_name="biodiversity_report.pdf",
184
+ mime="application/pdf"
185
+ )
186
+