src/bentoml/_internal/server/README.md
Create a sample Servie in hello.py:
# hello.py
import bentoml
from bentoml.io import JSON
svc = bentoml.legacy.Service("bento-server-test")
@svc.api(input=JSON(), output=JSON())
def predict(input_json):
return {'input_received': input_json, 'foo': 'bar'}
@svc.api(input=JSON(), output=JSON())
async def classify(input_json):
return {'input_received': input_json, 'foo': 'bar'}
# make sure to expose the asgi_app from the service instance
app = svc.asgi_app
Run the BentoServer:
bentoml serve hello:svc --reload
Alternatively, run the BentoServer directly with uvicorn:
uvicorn hello:app --reload
Send test request to the server:
curl -X POST localhost:8000/predict -H 'Content-Type: application/json' -d '{"abc": 123}'