updated flask server code