Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to integrate with other applications like flask, frappe or django? #317

Open
1 task done
KathirvelPriya opened this issue Feb 19, 2024 · 4 comments
Open
1 task done
Labels
Community Issue/PR opened by the open-source community Issue: General Question ❓ Issue contains a general question

Comments

@KathirvelPriya
Copy link

Question

How to integrate with other applications like flask, frappe or django?

Code/Examples

No response

Other information

No response

Which package?

None

Package version

No response

Python version

No response

OS

No response

Code of Conduct

@KathirvelPriya KathirvelPriya added Issue: General Question ❓ Issue contains a general question Status: Needs triage 🔍 Issue/PR needs triaging labels Feb 19, 2024
@antonymilne
Copy link
Contributor

antonymilne commented Feb 26, 2024

Hi @KathirvelPriya, thanks for your question. Under the hood, Vizro wraps Dash, which itself wraps a Flask app. Hence your question is basically the same as asking how to integrate a Dash app into a web framework.

  • any arguments that you pass into Dash should be passed exactly the same into Vizro, e.g. Dash(routes_pathname_prefix="/dashboard/") becomes Vizro(routes_pathname_prefix="/dashboard/")
  • the only difference is that the Flask server in Dash is exposed via app.server; in Vizro it's one level deeper in app.dash.server

If you search for how to integrate a Dash app into a web framework then you'll find lots of discussion of it e.g. on the plotly forums. Here's some pointers though:

Here's a very simple working example of Vizro inside an existing Flask app (which, as discussed in this article, might not be the way you actually want to do it, but serves as a good proof of concept).

import flask
import vizro
import vizro.models as vm

server = flask.Flask(__name__)

@server.route("/")
def home():
    return "Hello, Flask!"

page = vm.Page(title="My first page", components=[vm.Card(text="Hello, Vizro!")])
dashboard = vm.Dashboard(pages=[page])

app = vizro.Vizro(server=server, routes_pathname_prefix="/dashboard/").build(dashboard)
app.run()

http://127.0.0.1:8050/ gives the Flask app:
image

http://127.0.0.1:8050/dashboard/ gives the Vizro app:
image

@KathirvelPriya
Copy link
Author

Hi @antonymilne,
Thanks for your reply. I want to integrate with Frappe. I referred plotly-frappe-dash before. But it couldn't help in latest version of frappe.

@antonymilne
Copy link
Contributor

Ah, that's a pity. I recommend posting on the plotly forums to see if they can help you with that. Basically if you can get it working with pure Dash then you should easily be able to get it working with Vizro. And if you can't get it working with pure Dash then unfortunately you won't be able to get it working with Vizro.

@KathirvelPriya
Copy link
Author

Thank you for your response. I will try.

@maxschulz-COL maxschulz-COL added Community Issue/PR opened by the open-source community and removed Status: Needs triage 🔍 Issue/PR needs triaging labels Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Community Issue/PR opened by the open-source community Issue: General Question ❓ Issue contains a general question
Projects
None yet
Development

No branches or pull requests

3 participants