Skip to content

Commit

Permalink
[docs] change fastapi running examples to fastapi-cli
Browse files Browse the repository at this point in the history
  • Loading branch information
david-lev committed Sep 1, 2024
1 parent a668ca9 commit d5523b5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ def click_me(client: WhatsApp, clb: CallbackButton):
clb.reply_text("You clicked me!")
```

- To run the server, use [uvicorn](https://www.uvicorn.org/) (`pip install "uvicorn[standard]"`):
- To run the server, use [fastapi-cli](https://fastapi.tiangolo.com/#run-it) (`pip install "fastapi[standard]"`):

```bash
uvicorn wa:fastapi_app # see uvicorn docs for more options (port, host, reload, etc.)
fastapi dev wa.py # see uvicorn docs for more options (port, host, reload, etc.)
```

💫 **Async Usage**
Expand All @@ -129,7 +129,7 @@ async def hello(_: WhatsApp, msg: types.Message):
```

```bash
uvicorn wa:fastapi_app
fastapi dev wa.py
```

🎛 **Installation**
Expand Down
2 changes: 1 addition & 1 deletion docs/source/content/examples/sign_up_flow.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1446,7 +1446,7 @@ The last thing that we need to do is run the server:

.. code-block:: bash
uvicorn wa:fastapi_app
fastapi dev wa.py
What's Next?
------------
Expand Down
24 changes: 14 additions & 10 deletions docs/source/content/handlers/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,9 @@ See `Here <https://developers.facebook.com/docs/development/create-an-app/app-da
.. code-block:: python
:caption: main.py
:linenos:
:emphasize-lines: 5, 10, 11, 12, 13, 14, 20
:emphasize-lines: 4, 9, 10, 11, 12, 13
import fastapi
import uvicorn
from pywa import WhatsApp
fastapi_app = fastapi.FastAPI()
Expand All @@ -76,8 +75,11 @@ See `Here <https://developers.facebook.com/docs/development/create-an-app/app-da
... # register the handlers
if __name__ == '__main__':
uvicorn.run(fastapi_app, port=8080)
.. code-block:: bash
:caption: Terminal
fastapi dev main.py --port 8080
The port that fastapi is running on (``8080`` in the example above) must be the same port that the callback url is listening on (e.g. ``cloudflared tunnel --url http://localhost:8080``).

Expand Down Expand Up @@ -107,10 +109,9 @@ So, start the server:
.. code-block:: python
:caption: main.py
:linenos:
:emphasize-lines: 5, 10, 11, 17
:emphasize-lines: 4, 9, 10
import fastapi
import uvicorn
from pywa import WhatsApp
fastapi_app = fastapi.FastAPI()
Expand All @@ -124,8 +125,11 @@ So, start the server:
... # register the handlers
if __name__ == '__main__':
uvicorn.run(fastapi_app, port=8080)
.. code-block:: bash
:caption: Terminal
fastapi dev main.py --port 8080
The port that fastapi is running on (``8080`` in the example above) must be the same port that the callback url is listening on (e.g. ``cloudflared tunnel --url http://localhost:8080``).

Expand Down Expand Up @@ -235,7 +239,7 @@ The easiest way to register a callback function is to use the ``on_message`` and
.. code-block:: bash
:caption: Terminal
uvicorn main:fastapi_app
fastapi dev main.py
Using ``Handler`` objects
Expand Down Expand Up @@ -281,7 +285,7 @@ main code, or when you want to dynamically register handlers programmatically.
.. code-block:: bash
:caption: Terminal
uvicorn main:fastapi_app
fastapi dev main.py
.. seealso::

Expand Down

0 comments on commit d5523b5

Please sign in to comment.