Skip to content

Commit

Permalink
Commit 3
Browse files Browse the repository at this point in the history
  • Loading branch information
Queenwyne committed Jan 27, 2024
1 parent 2351ca1 commit b1880a6
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 46 deletions.
11 changes: 3 additions & 8 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,14 @@ def test_stories():
@app.route('/', methods=['GET', 'POST'])
def home():
if request.method == 'POST':
addiction_type = request.form.get('addiction-type')
duration = request.form.get('duration')
cause = request.form.get('cause')
severity = request.form.get('severity')
age = request.form.get('age')
gender = request.form.get('gender')
required_fields = ['addiction-type', 'duration', 'cause', 'severity', 'age', 'gender']
form_data = {field: request.form.get(field) for field in required_fields}

if not (addiction_type and duration and cause and severity and age and gender):
if not all(form_data.values()):
return "Please fill in all fields."

return "Form submitted successfully!"

return render_template('f_stories.html')

if __name__ == '__main__':
app.run(debug=True)
75 changes: 39 additions & 36 deletions static/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,45 +23,48 @@
}

/* Form Styles */
#addiction-form {
#addiction-form-section {
max-width: 600px;
margin: 50px auto;
padding: 20px;
background-color: #fff;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

#addiction-form h2 {
text-align: center;
color: #007bff;
}

#addiction-form label {
display: block;
margin: 10px 0;
}

#addiction-form input,
#addiction-form textarea,
#addiction-form select {
width: 100%;
padding: 10px;
margin-bottom: 15px;
border: 1px solid #ccc;
border-radius: 5px;
box-sizing: border-box;
}

#addiction-form button {
background-color: #007bff;
color: #fff;
padding: 10px 15px;
border: none;
border-radius: 5px;
cursor: pointer;
}

#addiction-form button:hover {
background-color: #0056b3;
}
}

#addiction-form-section h2 {
text-align: center;
color: #007bff;
}

#addiction-form-section label {
display: block;
margin: 10px 0;
}

#addiction-form-section input,
#addiction-form-section textarea,
#addiction-form-section select {
width: 100%;
padding: 10px;
margin-bottom: 15px;
border: 1px solid #ccc;
border-radius: 5px;
box-sizing: border-box;
}

#addiction-form-section button {
background-color: #007bff;
color: #fff;
padding: 10px 15px;
border: none;
border-radius: 5px;
cursor: pointer;
}

#addiction-form-section button:hover {
background-color: #0056b3;
}



2 changes: 1 addition & 1 deletion static/js/script.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
document.getElementById('addiction-form').addEventListener('submit', function(event) {
document.getElementById('addiction-form-section').addEventListener('submit', function(event) {
var form = event.target;
var isValid = true;

Expand Down
2 changes: 1 addition & 1 deletion templates/f_stories.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ <h2>Success Stories</h2>
</section>

<!-- Addiction Information Form -->
<section id="addiction-form">
<section id="addiction-form-section">
<h3>Tell Us About Your Addiction</h3>
<form action="#" method="post" id="addiction-form">
<label for="addiction-type">Type of Addiction:</label>
Expand Down

0 comments on commit b1880a6

Please sign in to comment.