Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import gradio as gr
|
2 |
from model import SpellChecker
|
|
|
3 |
|
4 |
checker = SpellChecker()
|
5 |
|
@@ -11,7 +12,6 @@ def check_text(text):
|
|
11 |
corrected_spelling = checker.correct_spelling(text)
|
12 |
corrected_grammar, grammar_issues = checker.correct_grammar(text)
|
13 |
|
14 |
-
# Format the output to match your HTML structure
|
15 |
output = f"""
|
16 |
<div class="output">
|
17 |
<h3>✅ Corrected Spelling:</h3>
|
@@ -35,16 +35,12 @@ def check_text(text):
|
|
35 |
|
36 |
return output
|
37 |
|
38 |
-
# Create custom Gradio interface
|
39 |
with gr.Blocks() as demo:
|
40 |
-
# Inject your entire HTML
|
41 |
gr.HTML(html_template)
|
42 |
|
43 |
-
# Add interactive components
|
44 |
text_input = gr.Textbox(visible=False, label="text")
|
45 |
output_area = gr.HTML()
|
46 |
|
47 |
-
# JavaScript to handle form submission
|
48 |
demo.load(
|
49 |
None,
|
50 |
None,
|
@@ -54,18 +50,22 @@ with gr.Blocks() as demo:
|
|
54 |
document.querySelector('form').onsubmit = async (e) => {
|
55 |
e.preventDefault();
|
56 |
const text = document.querySelector('textarea').value;
|
57 |
-
|
58 |
gradioApp.querySelector('#component-2 button').click();
|
59 |
}
|
60 |
}
|
61 |
"""
|
62 |
)
|
63 |
|
64 |
-
# Connect function to components
|
65 |
text_input.change(
|
66 |
check_text,
|
67 |
inputs=text_input,
|
68 |
outputs=output_area
|
69 |
)
|
70 |
|
71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
from model import SpellChecker
|
3 |
+
import os
|
4 |
|
5 |
checker = SpellChecker()
|
6 |
|
|
|
12 |
corrected_spelling = checker.correct_spelling(text)
|
13 |
corrected_grammar, grammar_issues = checker.correct_grammar(text)
|
14 |
|
|
|
15 |
output = f"""
|
16 |
<div class="output">
|
17 |
<h3>✅ Corrected Spelling:</h3>
|
|
|
35 |
|
36 |
return output
|
37 |
|
|
|
38 |
with gr.Blocks() as demo:
|
|
|
39 |
gr.HTML(html_template)
|
40 |
|
|
|
41 |
text_input = gr.Textbox(visible=False, label="text")
|
42 |
output_area = gr.HTML()
|
43 |
|
|
|
44 |
demo.load(
|
45 |
None,
|
46 |
None,
|
|
|
50 |
document.querySelector('form').onsubmit = async (e) => {
|
51 |
e.preventDefault();
|
52 |
const text = document.querySelector('textarea').value;
|
53 |
+
gradioApp.querySelector('#component-1 input').value = text;
|
54 |
gradioApp.querySelector('#component-2 button').click();
|
55 |
}
|
56 |
}
|
57 |
"""
|
58 |
)
|
59 |
|
|
|
60 |
text_input.change(
|
61 |
check_text,
|
62 |
inputs=text_input,
|
63 |
outputs=output_area
|
64 |
)
|
65 |
|
66 |
+
# Modified launch configuration for Hugging Face
|
67 |
+
demo.launch(
|
68 |
+
server_port=int(os.environ.get("PORT", 7860)), # Use Hugging Face's port
|
69 |
+
server_name="0.0.0.0", # Required for Hugging Face
|
70 |
+
share=False # Disable public sharing
|
71 |
+
)
|