Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,20 +2,17 @@ import gradio as gr
|
|
| 2 |
import requests
|
| 3 |
|
| 4 |
def latex_to_image(latex_code):
|
| 5 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
codecogs_url = "https://latex.codecogs.com/png.latex?"
|
| 7 |
-
# QuickLaTeX ์๋น์ค๋ฅผ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ (์ต์
)
|
| 8 |
-
quicklatex_url = "https://quicklatex.com/latex3.f"
|
| 9 |
-
|
| 10 |
-
# Codecogs ์๋น์ค๋ฅผ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ์ ๊ตฌํ
|
| 11 |
response_url = codecogs_url + requests.utils.quote(latex_code)
|
| 12 |
|
| 13 |
-
# QuickLaTeX ์๋น์ค๋ฅผ ์ฌ์ฉํ ๊ฒฝ์ฐ์ ๊ตฌํ (์ต์
, POST ์์ฒญ ํ์)
|
| 14 |
-
# response = requests.post(quicklatex_url, data={'formula': latex_code, 'fsize': '17px', 'fcolor': '000000'})
|
| 15 |
-
# if response.status_code == 200:
|
| 16 |
-
# response_url = response.text
|
| 17 |
-
|
| 18 |
return response_url
|
|
|
|
|
|
|
| 19 |
|
| 20 |
iface = gr.Interface(fn=latex_to_image,
|
| 21 |
inputs=gr.Textbox(label="Enter your LaTeX code here"),
|
|
|
|
| 2 |
import requests
|
| 3 |
|
| 4 |
def latex_to_image(latex_code):
|
| 5 |
+
# ๊ธฐ๋ณธ์ ์ธ LaTeX ๋ฌธ๋ฒ ๊ฒ์ฌ ์์
|
| 6 |
+
if not latex_code.startswith("\\"):
|
| 7 |
+
return "invalid equation: LaTeX commands should start with a backslash (\\)."
|
| 8 |
+
|
| 9 |
+
# ์ค์ ๋ ๋๋ง URL ์์ฑ ๋ก์ง
|
| 10 |
codecogs_url = "https://latex.codecogs.com/png.latex?"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
response_url = codecogs_url + requests.utils.quote(latex_code)
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
return response_url
|
| 14 |
+
|
| 15 |
+
|
| 16 |
|
| 17 |
iface = gr.Interface(fn=latex_to_image,
|
| 18 |
inputs=gr.Textbox(label="Enter your LaTeX code here"),
|