Victoria Oberascher commited on
Commit
45d8a3e
1 Parent(s): 002d3c8

try to fix flask server

Browse files
Files changed (2) hide show
  1. .DS_Store +0 -0
  2. app.py +4 -6
.DS_Store ADDED
Binary file (6.15 kB). View file
 
app.py CHANGED
@@ -49,23 +49,21 @@ def serve_assets(filename):
49
  abort(404) # File not found
50
 
51
  try:
 
52
  return send_from_directory(local_path / 'assets', safe_path)
53
  except Exception as e:
54
  print(f"Error serving file: {e}")
55
  abort(403) # Forbidden
56
 
57
  def run_flask():
58
- # Use '0.0.0.0' to ensure the server is accessible from any network interface
59
- app.run(port=7861, host='0.0.0.0')
60
 
61
  flask_thread = threading.Thread(target=run_flask)
62
  flask_thread.start()
63
 
64
- # Replace this with your Hugging Face Space's external URL
65
- external_url = "https://sea-ai-det-metrics.hf.space/" # Update this to match your space's URL
66
 
67
- # Update the image paths in the markdown to use the external Flask server URL
68
- markdown_content = re.sub(r'assets/([^)\s]+)', rf'{external_url}/assets/\1', markdown_content)
69
 
70
  with gr.Blocks() as demo:
71
  gr.Markdown(markdown_content)
 
49
  abort(404) # File not found
50
 
51
  try:
52
+ print("ja")
53
  return send_from_directory(local_path / 'assets', safe_path)
54
  except Exception as e:
55
  print(f"Error serving file: {e}")
56
  abort(403) # Forbidden
57
 
58
  def run_flask():
59
+ app.run(port=5001, host='0.0.0.0') # Ensure the server is accessible
 
60
 
61
  flask_thread = threading.Thread(target=run_flask)
62
  flask_thread.start()
63
 
64
+ # Update the image paths in the markdown to use the Flask server URL
65
+ markdown_content = re.sub(r'assets/([^)\s]+)', r'http://127.0.0.1:5001/assets/\1', markdown_content)
66
 
 
 
67
 
68
  with gr.Blocks() as demo:
69
  gr.Markdown(markdown_content)