在Apache服务器上的Flask应用程序中,当我提交表单时,render_template()显示索引.html关于Apache的

2024-04-29 22:42:24 发布

您现在位置:Python中文网/ 问答频道 /正文

我想解决下面描述的这个问题。在

当我提交表单时,它使用@app.route('/', methods = ['GET', 'POST']) POST method并在ubuntuapache服务器上呈现默认的index.html。在

这是我写的app.py文件。在

@app.route('/', methods = ['GET', 'POST'])
def whoami():
    try:
        if request.method == 'POST':
            ....
            ....
            return render_template("formElement/mainForm.html", session = session, jsonData = jsonData, jsonDataItm = jsonDataItm, fstListNm = fstListNm, jsonDataAll = jsonDataAll, jsonGrp = jsonGrp)         
        return render_template('formElement/whoami.html')
    except Exception as e:
        return str(e)

正如您在这段代码中看到的,当我提交表单时,浏览器应该使用一些参数呈现formElement/whoami.html页面。 但是当我提交表单时,浏览器会转到Apache服务器上的默认Ubuntuindex.html页面。在

这是我制作的flask.wsgi文件。在

^{pr2}$

{My source}位于

这是000-default.conf中的000-default.conf文件。在

<VirtualHost *:80>
    ....
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
    WSGIDaemonProcess flaskapp threads=5
    WSGIScriptAlias /lm_kyan/flaskapp /var/www/html/lm_kyan/flaskapp/flaskapp.wsgi

    <Directory flaskapp>
        WSGIProcessGroup flaskapp
        WSGIApplicationGroup %{GLOBAL}
        Order deny,allow
        Allow from all
    </Directory>

请注意,我已经将主页url设置为http://107.150.57.190/lm_kyan/flaskapp/。在

我不知道为什么会发生这个问题。在


Tags: 文件app表单getreturnhtmlpostroute