mirror of
https://github.com/wassname/ray.git
synced 2026-06-28 02:46:49 +08:00
18 lines
378 B
Python
18 lines
378 B
Python
import ray
|
|
from ray import serve
|
|
import requests
|
|
|
|
ray.init(num_cpus=8)
|
|
client = serve.start()
|
|
|
|
|
|
def echo(starlette_request):
|
|
return "hello " + starlette_request.query_params.get("name", "serve!")
|
|
|
|
|
|
client.create_backend("hello", echo)
|
|
client.create_endpoint("hello", backend="hello", route="/hello")
|
|
|
|
print(requests.get("http://127.0.0.1:8000/hello").text)
|
|
# > hello serve!
|