naman1102 commited on
Commit
63c0f13
·
1 Parent(s): fafdd5c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -13
app.py CHANGED
@@ -1,20 +1,18 @@
1
  import gradio as gr
 
2
 
3
- def process_repo_file(file):
4
- if file is None:
5
- return "No file uploaded."
6
- try:
7
- content = file.read().decode('utf-8')
8
- repo_ids = [line.strip() for line in content.splitlines() if line.strip()]
9
- return f"Uploaded repo IDs: {', '.join(repo_ids)}"
10
- except Exception as e:
11
- return f"Error reading file: {e}"
12
 
13
  demo = gr.Interface(
14
- fn=process_repo_file,
15
- inputs=gr.File(label="Upload a file with repo IDs"),
16
  outputs="text",
17
- title="Repo ID Uploader",
18
- description="Upload a text file containing one repo ID per line."
19
  )
20
  demo.launch()
 
1
  import gradio as gr
2
+ import re
3
 
4
+ def process_repo_input(text):
5
+ if not text:
6
+ return "No repo IDs provided."
7
+ # Split by newlines and commas, strip whitespace
8
+ repo_ids = [repo.strip() for repo in re.split(r'[\n,]+', text) if repo.strip()]
9
+ return f"Entered repo IDs: {', '.join(repo_ids)}"
 
 
 
10
 
11
  demo = gr.Interface(
12
+ fn=process_repo_input,
13
+ inputs=gr.Textbox(label="Enter repo IDs (comma or newline separated)", lines=5, placeholder="repo1, repo2\nrepo3"),
14
  outputs="text",
15
+ title="Repo ID Input",
16
+ description="Enter repo IDs separated by commas or new lines."
17
  )
18
  demo.launch()