ocrlatex / app.py
seawolf2357's picture
Update app.py
6e98020 verified
raw
history blame
1.1 kB
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()