knight knight - 19 days ago 5
HTML Question

Python newline not working from form data to string formating

I am new to Python and trying server side form handling. I have a simple html page with three input fields and and a textarea. When user fill in the details the form is processed and user presented with all the details he filled in. My only issue is that I can't get new line to work while printing the data in the main program after htmlTop() function. Tried many ways but without luck.
Following is my code that I have tried so far.


import cgi

def htmlTop():
<!Doctype html>
<html lang="en">
<meta charset="utf-8"/>
<title> Server Template </title>

def htmlTail():

def getData():
formData = cgi.FieldStorage()
firstname = formData.getvalue('firstName')
lastname = formData.getvalue("lastName")
email = formData.getvalue('email');
message = formData.getvalue('message')
dataList = [firstname , lastname , email , message]
return dataList

#main program construct

if __name__ == "__main__":
data = getData();
print("Welcome! {1} {0}".format(data[0],data[1]))
print("\n" + "Your email is {0}".format(data[2]))
print("\n" + "Your entered the following message: {0}".format(data[3]))



Try using <br> to add a line break instead of a newline character.