Spaces:
Sleeping
Sleeping
Add 4 files
Browse files- README.md +10 -7
- app.py +18 -0
- generate_output_files.py +4 -0
- parse_input_content.py +4 -0
README.md
CHANGED
|
@@ -1,11 +1,14 @@
|
|
| 1 |
---
|
|
|
|
| 2 |
title: File Generator
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
---
|
| 10 |
|
| 11 |
-
|
|
|
|
|
|
|
|
|
| 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")]
|