Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,35 +1,50 @@
|
|
1 |
import streamlit as st
|
2 |
import requests
|
3 |
|
4 |
-
HF_BACKEND_URL = "https://your-backend-url.hf.space" # Update
|
5 |
|
6 |
st.title("π Plagiarism & AI Detector")
|
7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
# Text Plagiarism
|
9 |
st.subheader("π Check Text Plagiarism")
|
10 |
text = st.text_area("Enter text to check for plagiarism")
|
11 |
if st.button("Check Plagiarism"):
|
12 |
-
|
13 |
-
st.json(
|
14 |
|
15 |
# Code Plagiarism
|
16 |
st.subheader("π» Check Code Plagiarism")
|
17 |
code = st.text_area("Paste code to check plagiarism")
|
18 |
if st.button("Check Code Plagiarism"):
|
19 |
-
|
20 |
-
st.json(
|
21 |
|
22 |
# AI Detection
|
23 |
st.subheader("π€ Detect AI-Generated Content")
|
24 |
ai_text = st.text_area("Enter text to check AI detection")
|
25 |
if st.button("Detect AI"):
|
26 |
-
|
27 |
-
st.json(
|
28 |
|
29 |
# PDF Upload
|
30 |
st.subheader("π Upload PDF for Plagiarism Check")
|
31 |
pdf = st.file_uploader("Upload a PDF file", type=["pdf"])
|
32 |
if pdf:
|
33 |
files = {"file": pdf.getvalue()}
|
34 |
-
|
35 |
-
st.json(
|
|
|
1 |
import streamlit as st
|
2 |
import requests
|
3 |
|
4 |
+
HF_BACKEND_URL = "https://your-backend-url.hf.space" # Update with your backend link
|
5 |
|
6 |
st.title("π Plagiarism & AI Detector")
|
7 |
|
8 |
+
# Function to safely call API
|
9 |
+
def fetch_api_response(url, params=None, files=None):
|
10 |
+
try:
|
11 |
+
if files:
|
12 |
+
response = requests.post(url, files=files)
|
13 |
+
else:
|
14 |
+
response = requests.post(url, params=params)
|
15 |
+
|
16 |
+
if response.status_code == 200:
|
17 |
+
return response.json()
|
18 |
+
else:
|
19 |
+
return {"error": f"API Error: {response.status_code} - {response.text}"}
|
20 |
+
except requests.exceptions.RequestException as e:
|
21 |
+
return {"error": f"Request Failed: {str(e)}"}
|
22 |
+
|
23 |
# Text Plagiarism
|
24 |
st.subheader("π Check Text Plagiarism")
|
25 |
text = st.text_area("Enter text to check for plagiarism")
|
26 |
if st.button("Check Plagiarism"):
|
27 |
+
result = fetch_api_response(f"{HF_BACKEND_URL}/check_text", params={"text": text})
|
28 |
+
st.json(result)
|
29 |
|
30 |
# Code Plagiarism
|
31 |
st.subheader("π» Check Code Plagiarism")
|
32 |
code = st.text_area("Paste code to check plagiarism")
|
33 |
if st.button("Check Code Plagiarism"):
|
34 |
+
result = fetch_api_response(f"{HF_BACKEND_URL}/check_code", params={"code": code})
|
35 |
+
st.json(result)
|
36 |
|
37 |
# AI Detection
|
38 |
st.subheader("π€ Detect AI-Generated Content")
|
39 |
ai_text = st.text_area("Enter text to check AI detection")
|
40 |
if st.button("Detect AI"):
|
41 |
+
result = fetch_api_response(f"{HF_BACKEND_URL}/detect_ai", params={"text": ai_text})
|
42 |
+
st.json(result)
|
43 |
|
44 |
# PDF Upload
|
45 |
st.subheader("π Upload PDF for Plagiarism Check")
|
46 |
pdf = st.file_uploader("Upload a PDF file", type=["pdf"])
|
47 |
if pdf:
|
48 |
files = {"file": pdf.getvalue()}
|
49 |
+
result = fetch_api_response(f"{HF_BACKEND_URL}/upload_pdf", files=files)
|
50 |
+
st.json(result)
|