memonfatima/BlogsbyFM
0
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 