列表在pyzo中更新,但不在localhost

时间:2019-04-26 18:11:29

标签: python html css flask

`嗨。我正在为学校设计一个项目,这是一个基于足球的网站。我的两个朋友正在设计主页,而我正在使用python脚本,该脚本可以使用户选择2个团队并预测最终得分。

我首先创建python代码,然后定义了一个名为poisson()的函数(这是数学定律的名称,它使我可以预测最终分数)。当我尝试使用pyzo时,everuthing的工作应该像预期的那样,我可以得到两个带有概率的列表,为每个团队设定一定数量的目标。 然后,我创建了一个html页面,其中显示2个选择,让用户选择要与哪个团队进行对抗,然后将结果显示在表/板上。

但是有两个问题: -第一个是用户第一次使用它,效果很好,但是一旦用户手动重新加载页面或返回选择其他团队重试该过程,表格就会越来越大,成倍增加就像列表中的单元格没有重置一样,只是在其中添加值,这与ypzo中的功能无关。 -第二个是,如果在我进行计算之前尝试重置列表,列表将显示在pyzo环境中,而不显示在html页面上。

我想知道为什么会这样,以及如何解决它。

我们必须使用flask来管理应用程序,该应用程序本应成为网站,而我是flask和html的新手。

感谢您阅读所有这些内容。 PS:对不起,我的英语不佳,而且代码令人作呕。

Python代码:`

def acceuil():

try:
    nom=request.form.get('choix_equipe_domicile')
except:
    nom=''
try:
    prenom=request.form.get('choix_equipe_ext')
except:
    prenom=''
try:
    i = int(request.form.get('choix_equipe_domicile'))
except:
    i=''
try:
    j = int(request.form.get('choix_equipe_ext'))
except:
    j = ''

if i != '' and j!='':

    poisson(liste_equipe[i], liste_equipe[j])
    return render_template("page_match_direct.html", 
    equipe_domicile=liste_equipe[i], equipe_ext=liste_equipe[j], 
    liste_proba_score_domicile = proba_equipe_domicile_list_trie, 
    liste_proba_score_ext = proba_equipe_ext_list_trie, match = match, 
    message = message_affiche, cote = cote_affiche, i=i, j=j)

else:
    return render_template("page_match_direct.html",nom=nom,prenom=prenom, 
    liste_equipe=liste_equipe, liste_proba_score_domicile=[], 
    liste_proba_score_ext=[])

if __name__ == '__main__':
    app.run(debug = True)

`

HTML部分:      <SCRIPT LANGUAGE="JavaScript"> for (var num=0; num<=9; num++) { document.writeln("<td>",num,"</td>"); } </SCRIPT> </tr> <tr> <td>probabilité de marqué x but {{ equipe_domicile }}</td> {% for i in liste_proba_score_domicile%} <td>{{ i }}</td> {% endfor %} </tr> <tr> <td>probabilité de marqué x but {{ equipe_ext }}</td> {% for i in liste_proba_score_ext%} <td>{{ i }}</td> {% endfor %} </tr> </table> </center> <DIV class=match_class><h1>{{ match }}</h1></DIV> <DIV class=message_class><h1>{{ message }}</h1></DIV> <DIV class=cote_class><h1>{{ cote }}</h1></DIV> {%endif%} <p> {{i}} {{j}} </p> {%endif%} </section> <button type="submit" name="reset" value="reset">REFRESH</button></a> </body>

0 个答案:

没有答案