Skip to content

Commit

Permalink
don't hoist flask_server.init_flask into __init__.py
Browse files Browse the repository at this point in the history
since the Flask dependency is in an extra
  • Loading branch information
snarfed committed Dec 13, 2022
1 parent 0387c2c commit 45ab294
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ response.write_json(output)

## Flask server

To serve XRPC methods in a [Flask](https://flask.palletsprojects.com/) web app, first instantiate a [`Server`](https://lexrpc.readthedocs.io/en/latest/source/lexrpc.html#lexrpc.server.Server) and register method handlers as described above. Then, attach the server to your Flask app with [`init_flask`](https://lexrpc.readthedocs.io/en/latest/source/lexrpc.html#lexrpc.flask_server.init_flask).
To serve XRPC methods in a [Flask](https://flask.palletsprojects.com/) web app, first install the lexrpc package with the `flask` extra, eg `pip install lexrpc[flask]`. Then, instantiate a [`Server`](https://lexrpc.readthedocs.io/en/latest/source/lexrpc.html#lexrpc.server.Server) and register method handlers as described above. Finally, attach the server to your Flask app with [`flask_server.init_flask`](https://lexrpc.readthedocs.io/en/latest/source/lexrpc.html#lexrpc.flask_server.init_flask).

```py
from flask import Flask
from lexrpc import init_flask
from lexrpc.flask_server import init_flask

# instantiate a Server like above
server = ...
Expand Down
1 change: 0 additions & 1 deletion lexrpc/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
from .client import Client
from .flask_server import init_flask
from .server import Server

0 comments on commit 45ab294

Please sign in to comment.