0
我有以下網址的代碼:http://localhost/summary/myfile.csv 我想讓url看起來像這樣:http:// localhost/summary? file = myfile.csv將參數值添加到燒瓶中的URL python
代碼將被寫入燒瓶。
我的第一個URL代碼如下:
@app.route('/summary/<filename>',methods = ['GET'])
def api_summary(filename):
url = 'C:\\Users\\Desktop\\myproject\\'
if os.path.exists(url + filename):
data = pandas.read_csv(url + filename)
Numeric_Summary = data.describe().to_dict()
resp = jsonify(Numeric_Summary)
resp.status_code = 200
return resp
怎麼會這樣?你有錯誤嗎?我改變了它,以便它接受任何文件名,而不僅僅是'myfile.csv'。 –
代碼工作,非常感謝@Nathan Villaescusa –
我做到了@Nathan Villaescusa –