How to use win32com with Dash

Hi everyone!
I’m new using dash but I think it awesome and has a lot of potential.
Recently I’ve tried to create an application that get information from a Windows application (SAP) and show this information with graphs to users.
I tried a test but I can’t connect with the program correctly with “win32com.client.GetObject(“SAPGUI”)” as I usually do. Here is my example where I link the function to the callback of the button and performance a simply task. It seems that when I run the server, the function of win32com is blocked.

import dash
import dash_html_components as html
import dash_core_components as dcc
import win32com.client
import sys

# Function to return to the initial page for ARP
def SAP_VolverInicio():
        # Conectamos
        SapGuiAuto = win32com.client.GetObject("SAPGUI")
        if not type(SapGuiAuto) == win32com.client.CDispatch:
        SapGuiAuto = win32com.client.GetObject("SAPGUI")
        application = SapGuiAuto.GetScriptingEngine
        connection = application.Children(0)
        session = connection.Children(0)
        cabecera = session.findById("wnd[0]").Text.strip()
        while cabecera[:15]  != "SAP Easy Access":
                cabecera = session.findById("wnd[0]").Text.strip()
                if session.Children.count > 1:
        session = None
        connection = None
        application = None
        SapGuiAuto = None

external_stylesheets = ['']

app = dash.Dash(__name__, external_stylesheets=external_stylesheets)

app.layout = html.Div([
    html.Div(dcc.Input(id='input-box', type='text')),
    html.Button('Submit', id='button',n_clicks=0),
             children='Enter a value and press submit')

    dash.dependencies.Output('container-button-basic', 'children'),
    [dash.dependencies.Input('button', 'n_clicks')]) 
def update_output(n_clicks):
    if n_clicks>0:
        return 'Test'

if __name__ == '__main__':
    app.run_server(debug=True, threaded=True)

Any help or idea would be very helpful.

Thank you very much.

I know this has been a while but wondering if you managed to figure it out?

I just want to say Thank you to @Victor_90 . I’ve been trying to get my head around how to get data from SAP, but hadn’t stumbled upon anything. This made my life SO MUCH EASIER.

I haven’t tried using SAP from within Dash, but if I do I’ll post my comments.

Thanks a lot!