Skip to content

Commit

Permalink
update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
Nanguage committed Sep 17, 2022
1 parent 973768d commit 32a4007
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 1 deletion.
2 changes: 2 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ignore:
- "oneface/qt.py"
49 changes: 49 additions & 0 deletions docs/dash_embed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Embeding dash to Flask web app

You can embed the oneFace generated dash app in a Flask application
to integrate a number of dash apps when needed,
or to leverage the power of Flask for additional functionality.

Here is an example where we have integrated the `add` and `mul` applications into a single Flask server:

```Python
# demo_flask_integrate.py
from flask import Flask, url_for
from oneface.dash_app import flask_route
from oneface.core import one
from oneface.dash_app import app

server = Flask("test_dash_app")

@flask_route(server, "/add")
@one
def add(a: int, b: int) -> int:
return a + b

@flask_route(server, "/mul")
@app(console_interval=500)
@one
def mul(a: int, b: int) -> int:
return a * b

@server.route("/")
def index():
return f"""
<h1>Hello</h1>
<div>
<p>You can run the following applications:</p>
<div>
<ul>
<li><a href="{url_for("add")}">add</a></li>
<li><a href="{url_for("mul")}">mul</a></li>
</ul>
</div>
</div>
"""

server.run("127.0.0.1", 8088)
```

![dash_flask_embed](./imgs/dash_app_flask_embed.gif)

Binary file added docs/imgs/dash_app_flask_embed.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ nav:
- Qt configs: qt_confs.md
- Dash configs: dash_confs.md
- Wrap command line: wrap_cli.md
- Embedding:
- dash_embed.md

markdown_extensions:
- pymdownx.highlight:
Expand Down
2 changes: 1 addition & 1 deletion oneface/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .core import one, Arg

__version__ = '0.1.6'
__version__ = '0.1.7'

__all__ = [one, Arg]

0 comments on commit 32a4007

Please sign in to comment.