box-metrics / app.py
Zwicii's picture
remove gradio default input output and replace it with markdown view
a4109a6 verified
raw
history blame contribute delete
902 Bytes
from pathlib import Path
import sys
import gradio as gr
def read_markdown(filepath):
with open(filepath, 'r') as file:
lines = file.readlines()
start_index = None
end_index = None
for i, line in enumerate(lines):
if line.strip() == '---':
if start_index is None:
start_index = i
else:
end_index = i
break
if end_index is None:
return ''.join(
lines) # If no end delimiter found, return entire content
else:
return ''.join(lines[end_index +
1:]) # Return content after end delimiter
local_path = Path(sys.path[0])
filepath = local_path / "README.md"
markdown_content = read_markdown(filepath)
with gr.Blocks() as demo:
gr.Markdown(markdown_content)
demo.launch()