Spaces:
Running
Running
move geojson function to utils
Browse files- .gitignore +21 -0
- app.py +11 -10
- utils/__init__.py +0 -0
- utils/utils.py +11 -0
.gitignore
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Python
|
2 |
+
__pycache__/
|
3 |
+
*.py[cod]
|
4 |
+
*$py.class
|
5 |
+
*.so
|
6 |
+
.Python
|
7 |
+
build/
|
8 |
+
develop-eggs/
|
9 |
+
dist/
|
10 |
+
downloads/
|
11 |
+
eggs/
|
12 |
+
.eggs/
|
13 |
+
lib/
|
14 |
+
lib64/
|
15 |
+
parts/
|
16 |
+
sdist/
|
17 |
+
var/
|
18 |
+
wheels/
|
19 |
+
*.egg-info/
|
20 |
+
.installed.cfg
|
21 |
+
*.egg
|
app.py
CHANGED
@@ -1,17 +1,11 @@
|
|
1 |
import gradio as gr
|
2 |
import json
|
|
|
3 |
|
4 |
-
def process_geojson(file):
|
5 |
-
if file is None:
|
6 |
-
return {}
|
7 |
-
|
8 |
-
try:
|
9 |
-
with open(file, 'r', encoding='utf-8') as f:
|
10 |
-
return json.load(f)
|
11 |
-
except Exception as e:
|
12 |
-
return {"error": str(e)}
|
13 |
|
|
|
14 |
with gr.Blocks() as ui:
|
|
|
15 |
with gr.Row():
|
16 |
with gr.Column():
|
17 |
file_input = gr.File(file_types=[".geojson"])
|
@@ -21,4 +15,11 @@ with gr.Blocks() as ui:
|
|
21 |
|
22 |
submit_btn.click(process_geojson, file_input, output)
|
23 |
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
import json
|
3 |
+
from utils.utils import process_geojson
|
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
+
# Interface
|
7 |
with gr.Blocks() as ui:
|
8 |
+
|
9 |
with gr.Row():
|
10 |
with gr.Column():
|
11 |
file_input = gr.File(file_types=[".geojson"])
|
|
|
15 |
|
16 |
submit_btn.click(process_geojson, file_input, output)
|
17 |
|
18 |
+
# Launch app
|
19 |
+
if __name__ == "__main__":
|
20 |
+
ui.launch(
|
21 |
+
server_name="0.0.0.0",
|
22 |
+
server_port=7860,
|
23 |
+
#mcp_server=True,
|
24 |
+
show_error=True
|
25 |
+
)
|
utils/__init__.py
ADDED
File without changes
|
utils/utils.py
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import json
|
2 |
+
|
3 |
+
def process_geojson(file):
|
4 |
+
if file is None:
|
5 |
+
return {}
|
6 |
+
|
7 |
+
try:
|
8 |
+
with open(file, 'r', encoding='utf-8') as f:
|
9 |
+
return json.load(f)
|
10 |
+
except Exception as e:
|
11 |
+
return {"error": str(e)}
|