CoolFace
Apppublic

memonfatima/BlogsbyFM

sourceHugging Faceapache-2.0updated 11mo agoView on Hugging Face
0likes
app.py37 linesDownload Raw Back to root
1import streamlit as st2from google import genai3import os4 5# Title6st.set_page_config(page_title="AI Blog Writer", page_icon="๐Ÿ“")7st.title("๐Ÿ“ AI Blog Writer using Gemini API")8 9# API Key Input10st.sidebar.title("๐Ÿ”‘ API Settings")11api_key = st.sidebar.text_input("Enter your GEMINI_API_KEY", type="password")12 13if api_key:14    os.environ["GEMINI_API_KEY"] = api_key15    client = genai.Client()16 17    st.success("โœ… Gemini API key set successfully!")18 19    # Blog input20    st.header("โœ๏ธ Generate Your Blog")21    topic = st.text_input("Enter your blog topic:", placeholder="e.g. The Future of Artificial Intelligence")22 23    if st.button("Generate Blog"):24        if topic.strip() == "":25            st.warning("โš ๏ธ Please enter a topic first.")26        else:27            with st.spinner("Generating blog... please wait โณ"):28                response = client.models.generate_content(29                    model="gemini-2.5-flash",30                    contents=f"Write a detailed SEO-friendly blog on the topic: {topic}"31                )32                blog = response.text33                st.subheader("๐Ÿ“ฐ Generated Blog:")34                st.write(blog)35else:36    st.info("Please enter your GEMINI_API_KEY in the sidebar to continue.")37