Problem redirecting from edit page back to view page to see updated posts

I am currently doing a note app project using flask and I am trying to do an edit page to edit notes that already exist. I think I have most of the code that I need to make it happen but for some reason when I try to submit the changes a 404 error pops up saying that that the url requested could not be found. At the end of the code you can notice that im trying to redirect into the 'view' url but when I test it out it does not work, instead it stays in the edit url and gives me the 404 error

This is the Edit Code in the flask app:

@app.route('/edit/<string:note_id>', methods=['GET','POST'])
@login_required
def editPost(note_id):
if request.method == "POST":
    Edtitle = request.form.get('edTitle')
    Edcontent = request.form.get("edContent")
    Edfavorite = request.form.get("checkEdFav")
    Edpost_date = datetime.datetime.now()

    if Edfavorite == "on":
        Edfavorite = 1
    else:
        Edfavorite = 0

    db.execute('UPDATE notes SET title = ?, context = ?, favorites = ?, date = ? WHERE id = ?', Edtitle, Edcontent, Edfavorite, Edpost_date, note_id)
    db.commit()

    return redirect(url_for('view'))

else:
    note = db.execute('SELECT * FROM notes WHERE id = ?', note_id)
    author_Fname = db.execute("SELECT FirstName FROM user WHERE id = ?", session['id'])
    author_Lname = db.execute("SELECT LastName FROM user WHERE id = ?", session['id'])
    return render_template('edit.html', note=note, Fname=author_Fname[0]['FirstName'], Lname=author_Lname[0]['LastName'])

This is the View Code in the flask app:

@app.route('/view', methods = ['GET', 'POST'])
@login_required
def viewNote():
  note = db.execute('SELECT * FROM notes WHERE user_id = ?', session["id"])
  author_Fname = db.execute("SELECT FirstName FROM user WHERE id = ?", session['id'])
  author_Lname = db.execute("SELECT LastName FROM user WHERE id = ?", session['id'])
  return render_template("View.html", note=note, Fname=author_Fname[0]['FirstName'], Lname=author_Lname[0]['LastName'])

This is the html code for the view page:

    {% extends 'layout.html' %}
     {% block body %}
     {% for i in note %}
     <form action = "{{ url_for('viewNote')}}" method="POST">
       <div class="card" style="width: 50rem;">
        <div class="card-header">
            <p id ="author">By: {{ Fname }} {{ Lname }}</p>
            <a href="{{ url_for('editPost',note_id = i.id) }}" style="margin-left: 25px;">Edit</a>
            <a href="{{ url_for('editPost',note_id = i.id) }}" style="margin-left: 15px;" >Delete</a>
            {% if i.favorites == 1 %}
            <img src="{{url_for('static', filename='images/favoriteStar.png')}}" style="width:40px; height:40px; margin-left:19%;">
            {% endif %}
            <p id="date"> {{ i.date }}</p>
        </div>
        <div class="card-body">
            <h5 class="card-title text-center" name="title" value="{{ i.title }}">{{ i.title }}</h5>
            <p class="card-text text-center">{{ i.context }}</p>
        </div>
    </div>
  </form>
 {% endfor %}
 {% endblock %}

This is the html code for the edit page:

    {% extends 'layout.html' %}
    {% block body %}

    <h1 class = "text-center" style="margin-top:1%;">Edit Note</h1>
    <form id="editNote" style="margin-top:1%;" action="{{url_for('editPost', note_id=note_id)}}" method="POST">
    {% for i in note %}
    <div class="container">
        <div class=" flex-child left">
            <div class="form-floating mb-3" style="width: 500px;">
                <input type="text" class="form-control" id="floatingInput" name=edTitle value="{{ i.title }}">
                <label for="floatingInput"> Note Title</label>
            </div>
            <div style="margin-left:170px; margin-top:20%; font-size: 20px">
                <p> Author: {{ Fname }} {{ Lname }}<p>
            </div>
            <div style="margin-left:150px; margin-top:20%;">
                {% if i.favorites == 1 %}
                <input type="checkbox" id="favorites" name=checkEdFav checked="on" style="width: 20px; height: 20px;">
                {% else %}
                <input type="checkbox" id="favorites" name=checkEdFav checked="off" style="width: 20px; height: 20px;">
                {% endif %}
                <label for="favorites" style="font-size:20px;">Add to favorites</label>
            </div>
            <div style="margin-left:150px; margin-top:20%;">
                <input type="submit" class="btn btn-primary" value="Edit Note" >
            </div>
            {% if message %}
            <div class="alert alert-primary" style="margin-top:10%; text-align: center;" role="alert"> {{ message }}</div>
            {% endif %}
        </div>
        <div class="flex-child right">
            <textarea class="notebox" name="edContent"> {{i.context}} </textarea>
        </div>
    </div>
    {% endfor%}
    </form>
    {% endblock %}

This is the url of the edit before the post request: Before Post

This is the url after the post request along with the error shown: After Post Error

If somebody has any idea how to fix this please let me know.

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum