Spaces:
Runtime error
Runtime error
import requests | |
import gradio as gr | |
def render_latex_to_image(latex_str): | |
""" | |
์ฌ์ฉ์์ LaTeX ๋ฌธ์์ด ์ ๋ ฅ์ ๋ฐ์์ CodeCogs LaTeX API๋ฅผ ์ด์ฉํด ์ด๋ฏธ์ง๋ก ๋ณํํ๊ณ , | |
์์ฑ๋ ์ด๋ฏธ์ง URL์ ๋ฐํํ๋ ํจ์ | |
""" | |
encoded_str = requests.utils.quote(latex_str) # URL์ ํฌํจ์ํฌ ์ ์๋๋ก LaTeX ๋ฌธ์์ด ์ธ์ฝ๋ฉ | |
# CodeCogs LaTeX ๋ ๋๋ง ์๋น์ค URL ์์ฑ | |
url = f"https://latex.codecogs.com/png.latex?{encoded_str}" | |
return url # ์์ฑ๋ ์ด๋ฏธ์ง์ 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", | |
description="Enter LaTeX code to render it into an image using the CodeCogs LaTeX Rendering API." | |
) | |
# Gradio ์ธํฐํ์ด์ค ์คํ | |
iface.launch() |