app = Flask(__name__)

@app.route('/')
def main():
    return data

def flaskThread():
    app.run()
if __name__ == '__main__':
    thread.start_new_thread(flaskThread, ())
Start a flask application in separate thread