@tim-hilt wrote:
I want my Dash-App to react to external POST-requests. Right now my solution is to integrate my Dash-App with a manually created Flask-server and to make POST-requests to that server.
The requests trigger the function, however i would have to reload the page for the change to be reflected in the shown layout. I tried out
flask.redirect(flask.request.url), which in theory should redirect me to the current URL, so it should refresh the page.However, that doesn’t happen. Here is my code:
import flask import dash import dash_html_components as html text_style = { 'color': 'blue', } server = flask.Flask(__name__) app = dash.Dash(__name__, server=server) app.layout = html.Div(id='dummy', children='Test text', style=text_style) @server.route('/test', methods=['POST']) def req(): print('Request triggered!') # For debugging purposes, prints to console if text_style['color'] == 'blue': # Toggle textcolor between red and blue text_style['color'] = 'red' else: text_style['color'] = 'blue' return flask.redirect(flask.request.url) # Should redirect to current page/ refresh page if __name__ == '__main__': app.run_server(debug=True)When i make a post request (
import requests; requests.post('http://127.0.0.1:8050/test')), i can see the messageRequest triggered!printed to the console and when i refresh the page, the textcolor changed.How can i automate the page refreshment? Is there maybe a way, that doesn’t require a melange of Flask and Dash?
Posts: 2
Participants: 2






