so here's my create page code:-
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="UTF-8" />
<link rel="stylesheet" href="{{url_for('static', filename='css/create.css')}}" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head>
<body>
<div class="container">
<div class="title">Details</div>
<div class="content">
<form action="{{ url_for('theme')}}" method="POST">
<div class="user-details">
<div class="input-box">
<span class="details">Full Name</span>
<input
id="name"
type="text"
name="name"
placeholder="Enter your name"
class="form-control"
aria-describedby="Name"
required
/>
</div>
<div class="input-box">
<span class="email">Email</span>
<input
type="text"
name="email"
placeholder="Enter your email"
required
aria-describedby="Email"
class="form-control"
/>
</div>
<div class="input-box">
<span class="profession">Profession</span>
<input
type="text"
name="profession"
placeholder="Enter your profession"
required
class = "form-control"
/>
</div>
<div class="input-box">
<span class="country">Country</span>
<input
type="text"
name="country"
placeholder="The country you live in"
required
class="form-control"
/>
</div>
<div class="input-box">
<span class="hobby">Hobby</span>
<input
type="text"
name="hobby"
placeholder="What do you like?"
required
class="form-control"
/>
</div>
<div class="input-box">
<span class="Phone_no.">Youtube channel</span>
<input
type="text"
name = "youtube"
class="form-control"
placeholder="Enter your youtube channel link"
/>
</div>
</div>
</div>
<div class="button">
<input type="submit" value="Submit">
</div>
</form>
</div>
</div>
</div>
</body>
</html>
where i enter my details. here's my python app sqlalchemy table:-
class details(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(80), nullable=False)
email = db.Column(db.String(120), nullable=False)
country = db.Column(db.String(120), nullable=False)
profession = db.Column(db.String(120), nullable=False)
hobby = db.Column(db.String(120))
def __repr__(self):
return '<Details %r>' % self.id
and i get the details entered by the user in the next page using:-
@app.route('/info/theme', methods =["GET", "POST"])
def theme():
if request.method == "POST":
name = request.form['name']
email = request.form['email']
country = request.form['country']
profession = request.form['profession']
hobby = request.form['hobby']
try:
db.session.add(details(name= name,email = email,country= country, profession =profession,hobby= hobby))
db.session.commit()
print("Successfully added")
print(name, email, country, profession, hobby)
return redirect(url_for('theme'))
except:
return "There was an issue adding your details"
else:
return render_template('theme_select.html')
and it does register the data in my db. But now to display it i do:-
@app.route('/result', methods=["POST", "GET"])
def result():
print(request.form)
name = details.query.order_by(details.name.desc()).first()
email = details.query.order_by(details.email.desc()).first()
hobby = details.query.order_by(details.hobby.desc()).first()
country = details.query.order_by(details.country.desc()).first()
profession = details.query.order_by(details.profession.desc()).first()
return render_template('/black_theme/index.html', name= name, email= email, profession= profession, hobby= hobby, country= country)
and for the html page using jinja:-
<!DOCTYPE html>
<html>
<head>
<title>Web Gen</title>
<link rel="stylesheet" type="text/css" href="{{url_for('static', filename='black_theme/css/style.css')}}">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
{% block content %}
<body>
<header>
<div class="main">
<ul>
<li class="active"><a href=>Home</a></li>
<li><a href="https://{youtube}.com">Blogs</a></li>
<link rel="stylesheet" href="css/style.css">
<li><a href="email">Contact me</a></li>
</ul>
</header>
</div>
<div class="title">
{% for name in details %}
<h1>hello I'm {{details.name}}</h1>
{% endfor %}
</div>
<main>
{%for name in details %}
{% for email in details %}
<p>Greetings, I am {{details.name}}. I'm a {{details.profession}} from {{details.country}}. I love {{details.hobby}}, Make sure to check out my blogs!</p>
{% endfor %}
{% endfor %}
<div>
</main>
</div>
</body>
{% endblock %}
</html>
but i get nothing. PLEASE HELP!! This is what i get:-enter image description here no texts