-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ignore: | ||
- "oneface/qt.py" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |