Skip to content

Commit

Permalink
Update app.py
Browse files Browse the repository at this point in the history
  • Loading branch information
muskan171105 authored Oct 11, 2024
1 parent e63e717 commit bc5bc14
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ def submit():
# Validate inputs
if not all([roll, fullname, email, phno, stream, event]):
return jsonify({"error": "All fields are required"}), 400
# Fetch file input correctly
profile_pic = request.files['profile']

# Fetch file input correctly (if applicable)
profile_pic = request.files.get('profile') # Use get to avoid KeyError

# Check if file is uploaded
if profile_pic:
Expand All @@ -61,6 +61,7 @@ def submit():
filepath = os.path.join(app.config['UPLOAD_FOLDER'], filename)
profile_pic.save(filepath)

# Create a database connection
connection = create_connection()
if connection is None:
raise Exception("Failed to connect to the database")
Expand Down

0 comments on commit bc5bc14

Please sign in to comment.