Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,22 +1,25 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
import
|
| 3 |
-
import tempfile
|
| 4 |
-
import os
|
| 5 |
|
| 6 |
-
def latex_to_image(
|
| 7 |
-
#
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
iface = gr.Interface(fn=latex_to_image,
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
iface.launch(share=True)
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import requests
|
|
|
|
|
|
|
| 3 |
|
| 4 |
+
def latex_to_image(latex_code):
|
| 5 |
+
# Codecogs ์๋น์ค๋ฅผ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ
|
| 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"),
|
| 22 |
+
outputs=gr.Image(label="Rendered LaTeX"),
|
| 23 |
+
title="LaTeX to Image Converter",
|
| 24 |
+
description="This tool converts LaTeX code to an image using an external rendering service.")
|
| 25 |
+
iface.launch()
|
|
|