Spaces:
Running
Running
import urllib.parse | |
import gradio as gr | |
def render_latex_to_image(latex_str): | |
""" | |
์ฌ์ฉ์์ LaTeX ๋ฌธ์์ด ์ ๋ ฅ์ ๋ฐ์์ Codecogs LaTeX Rendering API๋ฅผ ์ด์ฉํด ์ด๋ฏธ์ง(png ํ์)๋ก ๋ณํํ๊ณ , | |
์์ฑ๋ ์ด๋ฏธ์ง URL์ ๋ฐํํ๋ ํจ์ | |
""" | |
base_url = "https://latex.codecogs.com/png.latex?" | |
# LaTeX ๋ฌธ์์ด์ URL ์ธ์ฝ๋ฉ | |
encoded_str = urllib.parse.quote(latex_str) | |
# ์ต์ข ์ด๋ฏธ์ง URL ์์ฑ | |
image_url = f"{base_url}{encoded_str}" | |
return image_url | |
# Gradio ์ธํฐํ์ด์ค ์ ์ | |
iface = gr.Interface( | |
fn=render_latex_to_image, | |
inputs=gr.Textbox(placeholder="Enter LaTeX code here...", lines=4), | |
outputs=gr.Image(), | |
title="LaTeX to Image Renderer with CodeCogs API", | |
description="Enter LaTeX code to render it into an image using the CodeCogs LaTeX Rendering API." | |
) | |
# Gradio ์ธํฐํ์ด์ค ์คํ | |
iface.launch() |