Spaces:
Running
Running
import gradio as gr | |
import requests | |
def latex_to_image(latex_code): | |
# Codecogs ์๋น์ค๋ฅผ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ | |
codecogs_url = "https://latex.codecogs.com/png.latex?" | |
# QuickLaTeX ์๋น์ค๋ฅผ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ (์ต์ ) | |
quicklatex_url = "https://quicklatex.com/latex3.f" | |
# Codecogs ์๋น์ค๋ฅผ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ์ ๊ตฌํ | |
response_url = codecogs_url + requests.utils.quote(latex_code) | |
# QuickLaTeX ์๋น์ค๋ฅผ ์ฌ์ฉํ ๊ฒฝ์ฐ์ ๊ตฌํ (์ต์ , POST ์์ฒญ ํ์) | |
# response = requests.post(quicklatex_url, data={'formula': latex_code, 'fsize': '17px', 'fcolor': '000000'}) | |
# if response.status_code == 200: | |
# response_url = response.text | |
return response_url | |
iface = gr.Interface(fn=latex_to_image, | |
inputs=gr.Textbox(label="Enter your LaTeX code here"), | |
outputs=gr.Image(label="Rendered LaTeX"), | |
title="LaTeX to Image Converter", | |
description="This tool converts LaTeX code to an image using an external rendering service.") | |
iface.launch() |