Spaces:
Running
Running
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -112,7 +112,8 @@ def analyze(text, file, example, thresh, wl, bl):
|
|
| 112 |
|
| 113 |
conns = []
|
| 114 |
if file:
|
| 115 |
-
|
|
|
|
| 116 |
conns = parse_logs(content)
|
| 117 |
if not conns:
|
| 118 |
try: conns = json.loads(content)
|
|
@@ -144,8 +145,8 @@ with gr.Blocks(title="C2Sentinel") as demo:
|
|
| 144 |
|
| 145 |
with gr.Row():
|
| 146 |
with gr.Column(scale=2):
|
| 147 |
-
file_in = gr.File(label="Log File
|
| 148 |
-
text_in = gr.Textbox(label="Or Paste Logs", lines=5)
|
| 149 |
ex_in = gr.Dropdown(choices=[""] + list(EXAMPLES.keys()), value="", label="Example")
|
| 150 |
with gr.Column(scale=1):
|
| 151 |
thresh = gr.Slider(0.3, 0.8, 0.5, label="Threshold")
|
|
|
|
| 112 |
|
| 113 |
conns = []
|
| 114 |
if file:
|
| 115 |
+
with open(file, 'r', encoding='utf-8', errors='ignore') as f:
|
| 116 |
+
content = f.read()
|
| 117 |
conns = parse_logs(content)
|
| 118 |
if not conns:
|
| 119 |
try: conns = json.loads(content)
|
|
|
|
| 145 |
|
| 146 |
with gr.Row():
|
| 147 |
with gr.Column(scale=2):
|
| 148 |
+
file_in = gr.File(label="Log File (drag & drop or click)", type="filepath")
|
| 149 |
+
text_in = gr.Textbox(label="Or Paste Logs", lines=5, placeholder="Paste log content here...")
|
| 150 |
ex_in = gr.Dropdown(choices=[""] + list(EXAMPLES.keys()), value="", label="Example")
|
| 151 |
with gr.Column(scale=1):
|
| 152 |
thresh = gr.Slider(0.3, 0.8, 0.5, label="Threshold")
|