Skip to content

Commit 183450d

Browse files
authored
Add docs for mounting Mesop app (#892)
1 parent 41c919c commit 183450d

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

docs/guides/server-integration.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Server integration
2+
3+
Mesop allows you to integrate Mesop with other Python web servers like FastAPI or Flask by mounting the Mesop app which is a [WSGI](https://wsgi.readthedocs.io/en/latest/what.html) app.
4+
5+
This enables you to do things like:
6+
7+
- Serve local files (e.g. images)
8+
- Provide API endpoints (which can be called by the web component, etc.)
9+
10+
## API
11+
12+
The main API for doing this integration is the `create_wsgi_app` function.
13+
14+
::: mesop.server.wsgi_app.create_wsgi_app
15+
16+
## FastAPI example
17+
18+
For a working example of using Mesop with FastAPI, please take a look at this repo:
19+
[https://github.com/wwwillchen/mesop-fastapi](https://github.com/wwwillchen/mesop-fastapi)
20+
21+
> Note: you can apply similar steps to use any other web framework that allows you to mount a WSGI app.

mesop/server/wsgi_app.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ def create_app(
5151

5252
def create_wsgi_app(*, debug_mode: bool = False):
5353
"""
54-
Creates a WSGI app that can be used to run Mesop in a WSGI server.
54+
Creates a WSGI app that can be used to run Mesop in a WSGI server like gunicorn.
55+
56+
Args:
57+
debug_mode: If True, enables debug mode for the Mesop app.
5558
"""
5659
_app = None
5760

mkdocs.yml

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ nav:
2525
- Multi-Pages: guides/multi-pages.md
2626
- Auth: guides/auth.md
2727
- Theming: guides/theming.md
28+
- Server integration: guides/server-integration.md
2829
- Development:
2930
- Debugging: guides/debugging.md
3031
- Testing: guides/testing.md

0 commit comments

Comments
 (0)