tujestspam commited on
Commit
08e931d
·
verified ·
1 Parent(s): c51b403

Add 4 files

Browse files
Files changed (4) hide show
  1. README.md +10 -7
  2. app.py +18 -0
  3. generate_output_files.py +4 -0
  4. parse_input_content.py +4 -0
README.md CHANGED
@@ -1,11 +1,14 @@
1
  ---
 
2
  title: File Generator
3
- emoji: 📚
4
- colorFrom: red
5
- colorTo: green
6
- sdk: static
7
- pinned: false
8
- license: mit
9
  ---
10
 
11
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
1
  ---
2
+ license: apache-2.0
3
  title: File Generator
4
+ sdk: gradio
5
+ sdk_version: 3.39.0
6
+ app_file: app.py
7
+ emoji: 👀
8
+ colorFrom: green
9
+ colorTo: blue
10
  ---
11
 
12
+ # File Generator
13
+
14
+ This app takes a single input file and generates multiple output files based on its contents. You can try it out by saving the input file and opening `index.html` in your browser.
app.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ def generate_files(input_file):
4
+ output_files = []
5
+ # Parse the input file and generate multiple output files based on its contents
6
+ with open(input_file, "r") as f:
7
+ input_content = f.read()
8
+ output_files = parse_input_content(input_content)
9
+ return output_files
10
+
11
+ def parse_input_content(input_content):
12
+ # This function parses the input file and returns a list of output files
13
+ # The parsing logic can be arbitrarily complex and is not shown here for simplicity
14
+ return [("index.html", "ZAWARTOŚĆ PLIKU INDEX.HTML"), ("main.js", "ZAWARTOŚĆ PLIKU MAIN.JS"), ("readme.md", "ZAWARTOŚĆ PLIKU README.MD")]
15
+
16
+ demo = gr.Interface(generate_files, [gr.Textbox(label="Input file", lines=10)], "list", description="This app takes a single input file and generates multiple output files based on its contents. You can try it out by saving the input file and opening `index.html` in your browser.")
17
+
18
+ demo.launch()
generate_output_files.py ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ def generate_output_files(output_files):
2
+ for filename, content in output_files:
3
+ with open(filename, "w") as f:
4
+ f.write(content)
parse_input_content.py ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ def parse_input_content(input_content):
2
+ # This function parses the input file and returns a list of output files
3
+ # The parsing logic can be arbitrarily complex and is not shown here for simplicity
4
+ return [("index.html", "ZAWARTOŚĆ PLIKU INDEX.HTML"), ("main.js", "ZAWARTOŚĆ PLIKU MAIN.JS"), ("readme.md", "ZAWARTOŚĆ PLIKU README.MD")]