KX Community

Find answers, ask questions, and connect with our KX Community around the world.
KX Community Guidelines

Home Forums PyKX PyKX could not establish an IPC connection in the Flask app Re: PyKX could not establish an IPC connection in the Flask app

  • rocuinneagain

    Member
    February 9, 2024 at 12:00 am

    You example will run if you wait and only import pykx within the app

    from flask import Flask 
    #import pykx as kx <-- remove this 
    import json as j 
    app = Flask(__name__)
    
    @app.route("/") 
    def hello_kx(): 
        import pykx as kx 
        qcon=kx.QConnection(host='localhost', port=5000) 
        tables=qcon("tables[]").py() 
        import json as j 
        print(j.dumps(ports)) 
        return tables 
    
    if __name__ == '__main__': 
        app.run(host='127.0.0.1', debug=True, port=8100)