我已经在pythonanywhere上部署了成功运行的python flask应用程序。 只有主页显示,但是当我提交表格时抛出内部服务器错误。Python瓶应用程序部署在pythonanywhere错误提交
可能是什么情况。检查控制台网络时,我用过的请求链接没有被访问,并且出现错误。
我已成功在virtualenv中为该项目安装了请求和BeautifulSoup依赖项。
下面是代码
from flask import Flask,render_template
from flask import request
#lets do the scraping here
import requests
from bs4 import BeautifulSoup
app=Flask(__name__)
@app.route('/',methods=['GET','POST'])
def index():
if request.method== "GET" :
return render_template('home.html',result="")
else:
result=requests.post("jobkhulyo.com/")
soup1=BeautifulSoup(result.content)
return render_template('home.html',result=soup1);
if __name__=="__main__":
app.run(debug=True)
get方法运作良好,但对于POST方法,它抛出一个内部服务器错误。 Home.html是模板目录中的模板文件。在POST方法中加载相同的模板,但在提交Form时有一些值。