Update src/templates/mcp_server_http_template.py.jinja
Browse files
src/templates/mcp_server_http_template.py.jinja
CHANGED
|
@@ -133,14 +133,13 @@ str
|
|
| 133 |
{% endfor %}
|
| 134 |
|
| 135 |
if __name__ == "__main__":
|
| 136 |
-
# Get the
|
| 137 |
import os
|
| 138 |
from starlette.responses import HTMLResponse
|
| 139 |
|
| 140 |
app = mcp.http_app()
|
| 141 |
|
| 142 |
-
|
| 143 |
-
async def root():
|
| 144 |
"""Simple welcome page"""
|
| 145 |
return HTMLResponse("""
|
| 146 |
<html>
|
|
@@ -155,7 +154,9 @@ if __name__ == "__main__":
|
|
| 155 |
</html>
|
| 156 |
""")
|
| 157 |
|
| 158 |
-
#
|
|
|
|
|
|
|
| 159 |
import uvicorn
|
| 160 |
port = int(os.getenv("PORT", 7860))
|
| 161 |
uvicorn.run(app, host="0.0.0.0", port=port)
|
|
|
|
| 133 |
{% endfor %}
|
| 134 |
|
| 135 |
if __name__ == "__main__":
|
| 136 |
+
# Get the Starlette app produced by FastMCP and add a welcome route
|
| 137 |
import os
|
| 138 |
from starlette.responses import HTMLResponse
|
| 139 |
|
| 140 |
app = mcp.http_app()
|
| 141 |
|
| 142 |
+
async def root(request):
|
|
|
|
| 143 |
"""Simple welcome page"""
|
| 144 |
return HTMLResponse("""
|
| 145 |
<html>
|
|
|
|
| 154 |
</html>
|
| 155 |
""")
|
| 156 |
|
| 157 |
+
# Register the welcome route on the Starlette app and run with uvicorn
|
| 158 |
+
app.add_route("/", root, methods=["GET"])
|
| 159 |
+
|
| 160 |
import uvicorn
|
| 161 |
port = int(os.getenv("PORT", 7860))
|
| 162 |
uvicorn.run(app, host="0.0.0.0", port=port)
|