diff --git a/app.py b/app.py index f31300fe7f731afd1a978e9def66a788bf121c3d..1f1654cc0d5fcd4e496b73bc783f380b121258a3 100644 --- a/app.py +++ b/app.py @@ -2,7 +2,6 @@ import os import secrets from flask import Flask, render_template, request, redirect, url_for, send_from_directory, abort from flask_sqlalchemy import SQLAlchemy -from wtforms import StringField, SubmitField app = Flask(__name__, static_folder='static') app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 0 @@ -16,10 +15,6 @@ class Project(db.Model): title = db.Column(db.String(100), nullable=False) description = db.Column(db.Text, nullable=False) -class AddProjectForm(): - # Remove FlaskForm-related code - pass - @app.route('/') def home(): try: @@ -51,21 +46,23 @@ def portfolio(): def contact(): return render_template('contact.html') -# Updated route for adding a project with Flask-WTF form +# Updated route for adding a project without Flask-WTF form @app.route('/add_project', methods=['GET', 'POST']) def add_project(): - form = AddProjectForm() + if request.method == 'POST': + # Retrieve form data directly from request + title = request.form.get('title') + description = request.form.get('description') - if form.validate_on_submit(): # Print or log the form data to check if it's received - print(f"Received form data - Title: {form.title.data}, Description: {form.description.data}") + print(f"Received form data - Title: {title}, Description: {description}") - new_project = Project(title=form.title.data, description=form.description.data) + new_project = Project(title=title, description=description) db.session.add(new_project) db.session.commit() return redirect(url_for('home')) - return render_template('add_project.html', form=form) + return render_template('add_project.html') # Updated route for serving the 'my-cv.docx' file @app.route('/download_cv') @@ -89,5 +86,3 @@ def download_assessment(filename): app.logger.exception(f"Error serving assessment file: {str(e)}") abort(500) -if __name__ == '__main__': - app.run(debug=True, port=int(os.environ.get('PORT', 5000))) \ No newline at end of file