[Serve] Fix fastapi tutorial and update doc with deprecation warning
diff --git a/doc/source/serve/tutorials/web-server-integration.rst b/doc/source/serve/tutorials/web-server-integration.rst
index bbd8499731ead..a907cef4abbce 100644
--- a/doc/source/serve/tutorials/web-server-integration.rst
+++ b/doc/source/serve/tutorials/web-server-integration.rst
@@ -11,6 +11,11 @@ We give two examples, one using a `FastAPI <https://fastapi.tiangolo.com/>`__ we
 Scaling Up a FastAPI Application
 --------------------------------
 
+.. warning::
+
+  With the introduction of the new Deployments API in Ray 1.4.0, this tutorial no longer describes the best practice for integrating Ray Serve with FastAPI, and will soon be removed.
+  For details on the new and improved FastAPI integration, please see :ref:`serve-fastapi-http`.
+
 For this example, you must have either `Pytorch <https://pytorch.org/>`_ or `Tensorflow <https://www.tensorflow.org/>`_ installed, as well as `Huggingface Transformers <https://github.com/huggingface/transformers>`_ and `FastAPI <https://fastapi.tiangolo.com/>`_.  For example:
 
 .. code-block:: bash
@@ -19,7 +24,7 @@ For this example, you must have either `Pytorch <https://pytorch.org/>`_ or `Ten
 
 Here’s a simple FastAPI web server. It uses Huggingface Transformers to auto-generate text based on a short initial input using `OpenAI’s GPT-2 model <https://openai.com/blog/better-language-models/>`_.
 
-.. literalinclude:: ../../../../python/ray/serve/examples/doc/fastapi/fastapi.py
+.. literalinclude:: ../../../../python/ray/serve/examples/doc/fastapi/fastapi_simple.py
 
 To scale this up, we define a Ray Serve backend containing our text model and call it from Python using a ServeHandle:
 
diff --git a/python/ray/serve/examples/doc/fastapi/fastapi.py b/python/ray/serve/examples/doc/fastapi/fastapi_simple.py
similarity index 100%
rename from python/ray/serve/examples/doc/fastapi/fastapi.py
rename to python/ray/serve/examples/doc/fastapi/fastapi_simple.py
diff --git a/python/ray/serve/examples/doc/fastapi/servehandle_fastapi.py b/python/ray/serve/examples/doc/fastapi/servehandle_fastapi.py
index 0528c02fde0ee..08d93987b2e9e 100644
--- a/python/ray/serve/examples/doc/fastapi/servehandle_fastapi.py
+++ b/python/ray/serve/examples/doc/fastapi/servehandle_fastapi.py
@@ -13,8 +13,11 @@ class GPT2:
     def __init__(self):
         self.nlp_model = pipeline("text-generation", model="gpt2")
 
+    async def predict(self, query: str):
+        return self.nlp_model(query, max_length=50)
+
     async def __call__(self, request):
-        return self.nlp_model(await request.body(), max_length=50)
+        return self.predict(await request.body())
 
 
 @app.on_event("startup")  # Code to be run when the server starts.
@@ -30,4 +33,9 @@ async def startup_event():
 async def generate(query: str):
     # Get a handle to our deployment so we can query it in Python.
     handle = GPT2.get_handle()
-    return await handle.remote(query)
+    return await handle.predict.remote(query)
+
+
+@app.on_event("shutdown")  # Code to be run when the server shuts down.
+async def shutdown_event():
+    serve.shutdown()  # Shut down Ray Serve.

<!-- Thank you for your contribution! Please review https://github.com/ray-project/ray/blob/master/CONTRIBUTING.rst before opening a pull request. -->

<!-- Please add a reviewer to the assignee section when you create a PR. If you don't have the access to it, we will shortly find a reviewer and assign them to your PR. -->

## Why are these changes needed?

<!-- Please give a short summary of the change and the problem this solves. -->

## Related issue number

<!-- For example: "Closes #1234" -->
Closes #16756 
## Checks

- [x] I've run `scripts/format.sh` to lint the changes in this PR.
- [x] I've included any doc changes needed for https://docs.ray.io/en/master/.
- [x] I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
- Testing Strategy
   - [ ] Unit tests
   - [ ] Release tests
   - [x] Manual testing
   - [ ] This PR is not tested :(
