import streamlit as st import requests # Function to fetch medicine information from OpenFDA API def get_medicine_info(medicine_name): url = f"https://api.fda.gov/drug/label.json?search=openfda.brand_name:{medicine_name}&limit=1" response = requests.get(url) if response.status_code == 200: data = response.json() if "results" in data: result = data["results"][0] purpose = result.get("purpose", ["No purpose information available"])[0] indications = result.get("indications_and_usage", ["No usage information available"])[0] return purpose, indications return None, None # Streamlit UI st.title("Global Medicine Information Lookup") st.write("Enter a medicine name to get real-time information from OpenFDA.") # User input medicine_name = st.text_input("Enter Medicine Name", "").strip() # Fetch and display information if st.button("Search"): if medicine_name: purpose, indications = get_medicine_info(medicine_name) if purpose or indications: st.subheader(f"Information about {medicine_name}:") st.write(f"**Purpose:** {purpose}") st.write(f"**Used for:** {indications}") else: st.warning("Medicine not found in the OpenFDA database. Try another name.") else: st.warning("Please enter a medicine name.")