soiz commited on
Commit
b372f0d
·
verified ·
1 Parent(s): 28ba10c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -21
app.py CHANGED
@@ -1,28 +1,38 @@
 
1
  import subprocess
2
- import streamlit as st
3
- import os
4
 
5
  def clone_github_repo(repo_url, destination_folder=None):
6
- if destination_folder is None:
7
- destination_folder = repo_url.split('/')[-1].replace('.git', '')
 
 
 
 
8
  try:
9
- result = subprocess.run(["git", "clone", repo_url, destination_folder], check=True, capture_output=True, text=True)
10
- st.success(f"Repository cloned successfully: {repo_url} -> {destination_folder}")
11
- st.text(result.stdout)
 
12
  except subprocess.CalledProcessError as e:
13
- st.error(f"Error cloning repository: {e}")
14
- st.text(e.stderr)
15
-
16
- st.title("GitHub Repository Cloner")
17
- repo_url = st.text_input("Enter GitHub Repository URL", "https://github.com/NebulaServices/Nebula")
18
- destination_folder = st.text_input("Enter Destination Folder (Optional)")
19
-
20
- if st.button("Clone Repository"):
21
- clone_github_repo(repo_url, destination_folder)
22
 
23
- # Streamlit app configuration
24
- if 'STREAMLIT_PORT' not in os.environ:
25
- os.environ['STREAMLIT_PORT'] = '7860'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
 
27
- import os
28
- os.system("streamlit run app.py --server.port 7860")
 
1
+ import gradio as gr
2
  import subprocess
 
 
3
 
4
  def clone_github_repo(repo_url, destination_folder=None):
5
+ """
6
+ GitHubリポジトリをクローンします。
7
+
8
+ :param repo_url: クローンするリポジトリのURL
9
+ :param destination_folder: 保存先フォルダのパス(指定しない場合、リポジトリ名が使用されます)
10
+ """
11
  try:
12
+ if destination_folder is None:
13
+ destination_folder = repo_url.split('/')[-1].replace('.git', '')
14
+ subprocess.run(["git", "clone", repo_url, destination_folder], check=True)
15
+ return f"リポジトリ {repo_url} を {destination_folder} にクローンしました。"
16
  except subprocess.CalledProcessError as e:
17
+ return f"リポジトリのクローンに失敗しました: {e}"
 
 
 
 
 
 
 
 
18
 
19
+ def main():
20
+ # GitHubリポジトリのURL
21
+ repo_url = "https://github.com/NebulaServices/Nebula"
22
+
23
+ # クローン処理
24
+ clone_message = clone_github_repo(repo_url)
25
+
26
+ # Gradioインターフェースの作成
27
+ iface = gr.Interface(
28
+ fn=lambda: clone_message,
29
+ inputs=[],
30
+ outputs="text",
31
+ title="GitHub Repository Cloner",
32
+ description="GitHubリポジトリをクローンするアプリケーションです。"
33
+ )
34
+
35
+ iface.launch(server_name="0.0.0.0", server_port=7860)
36
 
37
+ if __name__ == "__main__":
38
+ main()