KeyarSrini commited on
Commit
1fc07a8
·
verified ·
1 Parent(s): 7691154

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +48 -0
app.py ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import openai
3
+ import os
4
+
5
+ # Set your OpenAI key (use HF Secrets when deploying)
6
+ openai.api_key = os.getenv("OPENAI_API_KEY")
7
+
8
+ def seo_audit(url):
9
+ if not url:
10
+ return "Please enter a valid URL."
11
+
12
+ prompt = f"""
13
+ You are SEOlytics AI, a world-class SEO Analyst.
14
+ Audit this URL as if it's a live site: {url}
15
+
16
+ Break your analysis into these parts:
17
+ 1. Basic Info (Title, Meta, OG tags)
18
+ 2. Technical SEO (Speed, HTTPS, Schema, Robots.txt)
19
+ 3. On-Page SEO (Headings, Keywords, Alt Tags)
20
+ 4. Content Quality (Readability, Word Count, Keyword Density)
21
+ 5. UX and Performance (Mobile-friendliness, CTA, Accessibility)
22
+ 6. SEO Score (0–100)
23
+ 7. Top 5 Priority Recommendations
24
+ """
25
+
26
+ try:
27
+ response = openai.ChatCompletion.create(
28
+ model="gpt-4",
29
+ messages=[
30
+ {"role": "system", "content": "You are an expert SEO analyst."},
31
+ {"role": "user", "content": prompt}
32
+ ]
33
+ )
34
+ return response['choices'][0]['message']['content']
35
+ except Exception as e:
36
+ return f"Error: {str(e)}"
37
+
38
+ # Gradio UI
39
+ demo = gr.Interface(
40
+ fn=seo_audit,
41
+ inputs=gr.Textbox(label="Enter Website URL"),
42
+ outputs=gr.Textbox(label="SEO Audit Report", lines=25),
43
+ title="SEOlytics AI",
44
+ description="AI-Powered SEO Analyzer – Just paste a URL and get insights!"
45
+ )
46
+
47
+ if __name__ == "__main__":
48
+ demo.launch()