CoolFace
Apppublic

Restricto/module1

sourceHugging Faceupdated 6mo agoView on Hugging Face
0likes
app.py62 linesDownload Raw Back to server
1# Copyright (c) Meta Platforms, Inc. and affiliates.2# All rights reserved.3#4# This source code is licensed under the BSD-style license found in the5# LICENSE file in the root directory of this source tree.6 7"""8FastAPI application for the Echo Environment.9 10This module creates an HTTP server that exposes the EchoEnvironment11over HTTP and WebSocket endpoints, compatible with MCPToolClient.12 13Usage:14    # Development (with auto-reload):15    uvicorn server.app:app --reload --host 0.0.0.0 --port 800016 17    # Production:18    uvicorn server.app:app --host 0.0.0.0 --port 8000 --workers 419 20    # Or run directly:21    uv run --project . server22"""23 24# Support both in-repo and standalone imports25try:26    # In-repo imports (when running from OpenEnv repository)27    from openenv.core.env_server.http_server import create_app28    from openenv.core.env_server.mcp_types import CallToolAction, CallToolObservation29 30    from .echo_environment import EchoEnvironment31except ImportError:32    # Standalone imports (when environment is standalone with openenv from pip)33    from openenv.core.env_server.http_server import create_app34    from openenv.core.env_server.mcp_types import CallToolAction, CallToolObservation35    from server.echo_environment import EchoEnvironment36 37# Create the app with web interface and README integration38# Pass the class (factory) instead of an instance for WebSocket session support39# Use MCP types for action/observation since this is a pure MCP environment40app = create_app(41    EchoEnvironment, CallToolAction, CallToolObservation, env_name="echo_env"42)43 44 45def main():46    """47    Entry point for direct execution via uv run or python -m.48 49    This function enables running the server without Docker:50        uv run --project . server51        python -m envs.echo_env.server.app52        openenv serve echo_env53 54    """55    import uvicorn56 57    uvicorn.run(app, host="0.0.0.0", port=8000)58 59 60if __name__ == "__main__":61    main()62