1

I am currently developing an app using Flask on an OVH server. I have two pages: a form and a result page.

Here is the app :

@application.route('/traitement', methods=['POST'])
@basic_auth.required
def traitement():
    result = request.form
    return render_template("traitement.html", **result)

And here is the template :

{{ name }} {{ surname }}

On my local server, everything is working well. But on OVH, jinja2 works differently: I need to add [0] to name and surname to get the values as if the dictionary were converted into a table :

{{ name[0] }} {{ surname[0] }}

I have been looking at the version of the packages I am using: there are identical. However, I am using python 3.7 locally whereas python 3.5 is used by OVH.

  • Do you think python versioning is the reason why jinja2 is asking for [0] ?
  • Does anyone know how to update python on OVH to 3.7 ? I am using Cloud Web servers.
  • If it is not possible to update python on OVH, how can I keep using dictionaries and not table on python 3.5 ?

Thank you in advance.

Guliup
  • 19
  • 2
  • I guess the problem comes from your HTML form ? Did you sync the HTML page as well ? – Kate Oct 09 '21 at 20:29

1 Answers1

0

So, it's weird but copying "result" in another dictionary made it work...

def traitement():
    result = request.form
    inputs = {}
    for cle, valeur in result.items():
        inputs[cle] = valeur
    return render_template("traitement.html", **inputs)

I don't really understand why but now it works perfectly !

Guliup
  • 19
  • 2