File size: 1,818 Bytes
c276e2c
 
 
74980cb
c276e2c
 
 
 
 
 
 
 
 
74980cb
c276e2c
 
 
 
 
 
 
74980cb
 
 
 
 
 
 
 
 
c276e2c
 
 
 
 
 
 
 
 
 
 
 
69d7ed0
 
 
 
 
 
 
 
c276e2c
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
"""FastAPI server for the Logistics Shipment RL Environment."""

from fastapi.responses import FileResponse
from fastapi.middleware.cors import CORSMiddleware
import os

try:
    from openenv.core.env_server.http_server import create_app
    from .environment import LogisticsShipmentEnvironment, LogisticsAction, LogisticsObservation
except ImportError:
    from openenv.core.env_server.http_server import create_app
    from server.environment import LogisticsShipmentEnvironment, LogisticsAction, LogisticsObservation

# Create the base application
app = create_app(
    LogisticsShipmentEnvironment,
    LogisticsAction,
    LogisticsObservation,
    env_name="logistics_shipment_env",
)

# Add CORS middleware to allow dashboard.html to talk to the server
app.add_middleware(
    CORSMiddleware,
    allow_origins=["*"],  # Allow all origins for the hackathon
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)

# Serve the beautiful dashboard at the root
@app.get("/")
async def serve_dashboard():
    dashboard_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "dashboard.html")
    if os.path.exists(dashboard_path):
        return FileResponse(dashboard_path)
    return {"error": "Dashboard not found", "path": dashboard_path}

@app.get("/health")
async def health():
    return {"status": "ok", "env": "logistics_shipment_env"}

# Serve the slide deck presentation
@app.get("/slides")
async def serve_slides():
    slides_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "slides.html")
    if os.path.exists(slides_path):
        return FileResponse(slides_path, media_type="text/html")
    return {"error": "Slides not found"}


def main():
    import uvicorn
    uvicorn.run(app, host="0.0.0.0", port=8000)


if __name__ == "__main__":
    main()