【发布时间】:2017-05-26 21:59:57
【问题描述】:
我开始学习如何在 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 Internal Server Error 因为 OSError: File 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 ,我刚写下来,可以吗?或者你还想看吗?
标签: csv web-applications flask structure pythonanywhere