Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,22 +1,25 @@
|
|
1 |
-
import
|
2 |
import gradio as gr
|
3 |
|
4 |
def render_latex_to_image(latex_str):
|
5 |
"""
|
6 |
-
์ฌ์ฉ์์ LaTeX ๋ฌธ์์ด ์
๋ ฅ์ ๋ฐ์์
|
7 |
์์ฑ๋ ์ด๋ฏธ์ง URL์ ๋ฐํํ๋ ํจ์
|
8 |
"""
|
9 |
-
|
10 |
-
#
|
11 |
-
|
12 |
-
|
|
|
|
|
|
|
13 |
|
14 |
# Gradio ์ธํฐํ์ด์ค ์ ์
|
15 |
iface = gr.Interface(
|
16 |
fn=render_latex_to_image,
|
17 |
inputs=gr.Textbox(placeholder="Enter LaTeX code here...", lines=4),
|
18 |
outputs=gr.Image(),
|
19 |
-
title="LaTeX to Image Renderer",
|
20 |
description="Enter LaTeX code to render it into an image using the CodeCogs LaTeX Rendering API."
|
21 |
)
|
22 |
|
|
|
1 |
+
import urllib.parse
|
2 |
import gradio as gr
|
3 |
|
4 |
def render_latex_to_image(latex_str):
|
5 |
"""
|
6 |
+
์ฌ์ฉ์์ LaTeX ๋ฌธ์์ด ์
๋ ฅ์ ๋ฐ์์ Codecogs LaTeX Rendering API๋ฅผ ์ด์ฉํด ์ด๋ฏธ์ง(png ํ์)๋ก ๋ณํํ๊ณ ,
|
7 |
์์ฑ๋ ์ด๋ฏธ์ง URL์ ๋ฐํํ๋ ํจ์
|
8 |
"""
|
9 |
+
base_url = "https://latex.codecogs.com/png.latex?"
|
10 |
+
# LaTeX ๋ฌธ์์ด์ URL ์ธ์ฝ๋ฉ
|
11 |
+
encoded_str = urllib.parse.quote(latex_str)
|
12 |
+
# ์ต์ข
์ด๋ฏธ์ง URL ์์ฑ
|
13 |
+
image_url = f"{base_url}{encoded_str}"
|
14 |
+
|
15 |
+
return image_url
|
16 |
|
17 |
# Gradio ์ธํฐํ์ด์ค ์ ์
|
18 |
iface = gr.Interface(
|
19 |
fn=render_latex_to_image,
|
20 |
inputs=gr.Textbox(placeholder="Enter LaTeX code here...", lines=4),
|
21 |
outputs=gr.Image(),
|
22 |
+
title="LaTeX to Image Renderer with CodeCogs API",
|
23 |
description="Enter LaTeX code to render it into an image using the CodeCogs LaTeX Rendering API."
|
24 |
)
|
25 |
|