我開始學習如何在pythonanywhere工作,所以我有一些問題... 我的web應用程序的結構爲:燒瓶pythonanywhere服務器中的文件結構?
/home/mentor/mysite/servidor/ here I've run.py and the folder app
inside app there's init.py , views.py and the folders: static,scripts,templates
我的問題是,在網絡裏面有一種形式,當有人點擊按鈕,在views.py中調用腳本中的函數。該功能需要讀取.csv文件(我將該文件保存在.../servidor /中)。
但網頁不運行,它返回500內部服務器錯誤,因爲OSError:文件b'Names.csv'不存在。 爲什麼我可以解決這個問題?我需要放置該文件的位置?這是run.py或WSGI配置文件的問題嗎?
謝謝!
PD:該代碼
在viwes.py:
from .scripts.file import function
@app.route('/func', methods=['POST'])
def resp():
l=[request.form['d1'].....]
f=function(l)
.....
在腳本文件夾file.py:
import pandas as pd
def function(l):
df=pd.read_csv('Names.csv') #Here is the problem!
.....
您能否包含訪問該文件的代碼? –
@Luis Orduz,我只是把它寫下來,沒關係?還是你想再看? –