Vidhiii1711 commited on
Commit
e445f2f
Β·
1 Parent(s): 9d5d2ab

updated smart-farm.html

Browse files
server/__pycache__/app.cpython-313.pyc CHANGED
Binary files a/server/__pycache__/app.cpython-313.pyc and b/server/__pycache__/app.cpython-313.pyc differ
 
server/app.py CHANGED
@@ -46,7 +46,7 @@ except (ModuleNotFoundError, ImportError):
46
  from server.my_env_environment import FarmEnvironment
47
  from pathlib import Path
48
  from fastapi import Request
49
- from fastapi.responses import JSONResponse,FileResponse,PlainTextResponse
50
 
51
  from fastapi.staticfiles import StaticFiles
52
 
@@ -63,8 +63,21 @@ from fastapi.middleware.cors import CORSMiddleware
63
  # Serve the UI
64
  @app.get("/ui")
65
  async def serve_ui():
66
- ui_path = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "smart-farm-ui.html")
67
- return FileResponse(ui_path, media_type="text/html")
 
 
 
 
 
 
 
 
 
 
 
 
 
68
  @app.get("/openenv.yaml", response_class=PlainTextResponse)
69
  async def serve_openenv_spec():
70
  """Serve the OpenEnv spec file β€” required for validation."""
 
46
  from server.my_env_environment import FarmEnvironment
47
  from pathlib import Path
48
  from fastapi import Request
49
+ from fastapi.responses import JSONResponse,FileResponse,PlainTextResponse,HTMLResponse
50
 
51
  from fastapi.staticfiles import StaticFiles
52
 
 
63
  # Serve the UI
64
  @app.get("/ui")
65
  async def serve_ui():
66
+ """Serve the Smart Farm UI frontend."""
67
+ try:
68
+ # Look for HTML file in multiple locations
69
+ possible_paths = [
70
+ os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "smart-farm-ui.html"),
71
+ os.path.join(os.path.dirname(os.path.abspath(__file__)), "smart-farm-ui.html"),
72
+ "smart-farm-ui.html",
73
+ ]
74
+ for path in possible_paths:
75
+ if os.path.exists(path):
76
+ with open(path, "r", encoding="utf-8") as f:
77
+ return HTMLResponse(content=f.read())
78
+ return HTMLResponse(content="<h1>UI file not found</h1>", status_code=404)
79
+ except Exception as e:
80
+ return HTMLResponse(content=f"<h1>Error: {e}</h1>", status_code=500)
81
  @app.get("/openenv.yaml", response_class=PlainTextResponse)
82
  async def serve_openenv_spec():
83
  """Serve the OpenEnv spec file β€” required for validation."""
my_env/smart-farm-ui.html β†’ smart-farm-ui.html RENAMED
@@ -342,7 +342,7 @@
342
  <div class="task-score-bar"><div class="task-score-fill t3" id="fill3"></div></div>
343
  <div class="task-score-num" id="score3">β€” / 1.0</div>
344
  </div>
345
- </div>
346
 
347
  </div>
348
 
@@ -351,9 +351,7 @@
351
  </footer>
352
 
353
  <script>
354
- const BACKEND_URL = window.location.hostname === 'localhost'
355
- ? 'http://localhost:8000'
356
- : 'https://shesync-meta-hackathon-project.hf.space';
357
 
358
  let selectedTask = 1;
359
  let currentDay = 0;
 
342
  <div class="task-score-bar"><div class="task-score-fill t3" id="fill3"></div></div>
343
  <div class="task-score-num" id="score3">β€” / 1.0</div>
344
  </div>
345
+ </div>const
346
 
347
  </div>
348
 
 
351
  </footer>
352
 
353
  <script>
354
+ BACKEND_URL = window.location.hostname;
 
 
355
 
356
  let selectedTask = 1;
357
  let currentDay = 0;