mdasad3617 commited on
Commit
5034a48
·
verified ·
1 Parent(s): 3af81f3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -1,6 +1,7 @@
1
  import json
2
  import gradio as gr
3
  import tempfile
 
4
 
5
  def update_swagger(swagger_content):
6
  try:
@@ -17,10 +18,10 @@ def update_swagger(swagger_content):
17
  # Convert back to JSON string
18
  updated_swagger = json.dumps(swagger_data, indent=2)
19
 
20
- # Save to a temporary file for download
21
- with tempfile.NamedTemporaryFile(delete=False, suffix=".json") as temp_file:
22
- temp_file.write(updated_swagger.encode("utf-8"))
23
- temp_file_path = temp_file.name
24
 
25
  return updated_swagger, temp_file_path
26
  except Exception as e:
 
1
  import json
2
  import gradio as gr
3
  import tempfile
4
+ import os
5
 
6
  def update_swagger(swagger_content):
7
  try:
 
18
  # Convert back to JSON string
19
  updated_swagger = json.dumps(swagger_data, indent=2)
20
 
21
+ # Save to a named temporary file for download
22
+ temp_file_path = os.path.join(tempfile.gettempdir(), "updatedswagger.json")
23
+ with open(temp_file_path, "w", encoding="utf-8") as temp_file:
24
+ temp_file.write(updated_swagger)
25
 
26
  return updated_swagger, temp_file_path
27
  except Exception as e: