|
import gradio as gr
|
|
import os
|
|
from php_parser import PHPParser
|
|
|
|
|
|
def analyze_php_file(uploaded_file):
|
|
try:
|
|
|
|
with open(uploaded_file.name, 'r') as file:
|
|
php_code = file.read()
|
|
|
|
|
|
parser = PHPParser()
|
|
analysis = parser.parse(php_code)
|
|
|
|
|
|
seo_suggestions = "Dodaj H1 tagove, smanji vreme učitavanja..."
|
|
|
|
|
|
return f"Analiziran fajl: {uploaded_file.name}\n\nRezultati analize:\n{analysis}\n\nSEO predlozi:\n{seo_suggestions}"
|
|
|
|
except Exception as e:
|
|
return f"Greška u analizi fajla: {str(e)}"
|
|
|
|
|
|
upload_input = gr.File(label="Upload PHP fajl", file_types=['php'])
|
|
output_text = gr.Textbox(label="Rezultat analize")
|
|
|
|
|
|
demo = gr.Interface(
|
|
fn=analyze_php_file,
|
|
inputs=upload_input,
|
|
outputs=output_text,
|
|
title="PHP Code Analyzer",
|
|
description="Uploaduj PHP fajl da bi dobio automatsku analizu i SEO preporuke."
|
|
)
|
|
|
|
if __name__ == "__main__":
|
|
demo.launch()
|
|
|