烧瓶正在引发RuntimeError:在请求上下文之外工作

时间:2019-12-08 05:17:40

标签: python flask

邮递员接受http://127.0.0.1:5000/out以下的json POST请求

def fixup_latlon_signs(row):
    row['lat'] = row['lat'] * (-1) ** (row['lat-dir'] == 'S')
    row['lon'] = row['lon'] * (-1) ** (row['lon-dir'] == 'W')
    return row

df2.apply(fixup_latlon_signs, axis=1)

# Then insert the non-NA rows we processed back into the parent dataframe:
df.update(df2)

# Strictly we can drop 'lat-dir','lon-dir' now...

代码在下面

{"filters": [{"id": 1}] }

错误在下面

from flask import Flask from flask import request, Response app = Flask(__name__) class MyServer: def __init__(self): self.json_request = request.get_json() self.data = json.loads(json.dumps(json_request)) #return data self.globalData = Response(self.data, mimetype='application/json') return self.globalData @app.route('/out/', methods=[ 'POST']) def out(): return (my_server.globalData) #select some random data to return my_server = MyServer() if __name__ == "__main__": app.run()

0 个答案:

没有答案