Modify Gradio UI
Browse files
app.py
CHANGED
@@ -99,16 +99,6 @@ def generate_readme(query):
|
|
99 |
return f"Error: {response.status_code}\n{response.text}"
|
100 |
except Exception as e:
|
101 |
return f"Exception: {str(e)}"
|
102 |
-
|
103 |
-
def fetch_github_content(url: str) -> str:
|
104 |
-
try:
|
105 |
-
response = requests.get(url, timeout=20)
|
106 |
-
response.raise_for_status()
|
107 |
-
markdown_content = markdownify(response.text)
|
108 |
-
markdown_content = re.sub(r"\n{3,}", "\n\n", markdown_content)
|
109 |
-
return markdown_content
|
110 |
-
except Exception as e:
|
111 |
-
return f"Error fetching content: {str(e)}"
|
112 |
|
113 |
with gr.Blocks() as demo:
|
114 |
# 제목 가운데 정렬
|
@@ -117,6 +107,9 @@ with gr.Blocks() as demo:
|
|
117 |
label="GitHub Repository URL",
|
118 |
placeholder="Enter the GitHub repository URL (e.g. https://github.com/username/repo)"
|
119 |
)
|
|
|
|
|
|
|
120 |
with gr.Row():
|
121 |
with gr.Column():
|
122 |
gr.Markdown("#### 🖼️ Preview (Markdown Rendered)")
|
@@ -135,16 +128,19 @@ with gr.Blocks() as demo:
|
|
135 |
interactive=False,
|
136 |
show_copy_button=True
|
137 |
)
|
138 |
-
generate_btn = gr.Button("Generate README.md")
|
139 |
-
|
140 |
-
# 버튼 클릭 시 두 박스 모두 채움
|
141 |
-
def dual_output(readme):
|
142 |
-
return readme, readme
|
143 |
|
|
|
144 |
generate_btn.click(
|
145 |
generate_readme,
|
146 |
inputs=repo_input,
|
147 |
-
outputs=
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
148 |
)
|
149 |
|
150 |
if __name__ == "__main__":
|
|
|
99 |
return f"Error: {response.status_code}\n{response.text}"
|
100 |
except Exception as e:
|
101 |
return f"Exception: {str(e)}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
|
103 |
with gr.Blocks() as demo:
|
104 |
# 제목 가운데 정렬
|
|
|
107 |
label="GitHub Repository URL",
|
108 |
placeholder="Enter the GitHub repository URL (e.g. https://github.com/username/repo)"
|
109 |
)
|
110 |
+
|
111 |
+
generate_btn = gr.Button("Generate README.md")
|
112 |
+
|
113 |
with gr.Row():
|
114 |
with gr.Column():
|
115 |
gr.Markdown("#### 🖼️ Preview (Markdown Rendered)")
|
|
|
128 |
interactive=False,
|
129 |
show_copy_button=True
|
130 |
)
|
|
|
|
|
|
|
|
|
|
|
131 |
|
132 |
+
# 버튼 클릭 시 왼쪽 박스만 채움
|
133 |
generate_btn.click(
|
134 |
generate_readme,
|
135 |
inputs=repo_input,
|
136 |
+
outputs=readme_preview
|
137 |
+
)
|
138 |
+
|
139 |
+
# 왼쪽 박스가 바뀔 때마다 오른쪽 미리보기도 자동 렌더링
|
140 |
+
readme_preview.change(
|
141 |
+
lambda md: md,
|
142 |
+
inputs=readme_preview,
|
143 |
+
outputs=readme_markdown
|
144 |
)
|
145 |
|
146 |
if __name__ == "__main__":
|