0

I'm brand new to Flask and cant seem to figure out why im receiving the 404 error page when rendering a template

PYTHON CODE
Here i'm trying to edit a request, when the edit button is clicked i want to be redirected to the "edit_request.html" page.

@app.route("/edit_request/<request_id>", methods=["GET", "POST"])
def edit_request(request_id):
    request = mongo.db.user_details.find_one({"_id": ObjectId(request_id)})
    return render_template("edit_request.html", request=request)

HTML CODE
Here is the link that, when clicked, should fire up the "edit_request" route but instead i receive "The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again" message

<a href="{{ url_for('edit_request', request_id=request._id) }}">
    <li class="req_menu_item">Edit Request<br>
        <img src="{{ url_for('static', filename='images/makeedit_icon.png') }}" alt=""
            class="chat_icon">
    </li>
</a>

Also, here is a screenshot of my templates folder containing the "edit_request.html" page.

enter image description here

And a screenshot of the full error: enter image description here

Screenshot of SocketIO code:
enter image description here

SocketIO sock.bind
enter image description here
Any help would be greatly appreciated, if any additional information is needed i will be happy to provide. Thanks!

HoldOffHunger
  • 18,769
  • 10
  • 104
  • 133
Delroy Brown
  • 125
  • 1
  • 7
  • Could you please provide the complete error message? i.e. when you have a look at the console or when you run Flask in debug mode, you see the complete message also in the browser. – Jürgen Gmach Aug 30 '20 at 10:26
  • @J.G. I've updated the question with the full error. – Delroy Brown Aug 30 '20 at 10:31
  • from the screenshot you added, it seems that the error is somewhere else in the code where you're using threading and socket. Can you put this part of code – AnaS Kayed Aug 30 '20 at 10:32
  • @AnaSKayed Sure, I use a few lines of code for a small chat function using SocketIO. I've updated the question with the screenshot. Bare in mind, all other templates load with no issues – Delroy Brown Aug 30 '20 at 10:37
  • the problem is in the part where you're initializing the socket, in `sock.bind(addr)`. can you post this part – AnaS Kayed Aug 30 '20 at 10:39
  • @AnaSKayed That part of the code looks like its coming from one of the site packages for SocketIO, convenience.py. I've updated the question with that screenshot as well. – Delroy Brown Aug 30 '20 at 10:46
  • I'm not very good in socket, but look at [this question](https://stackoverflow.com/questions/12362542/python-server-only-one-usage-of-each-socket-address-is-normally-permitted), it is the same error as yours. Maybe you should change `sock.setsockopt(SOL_SOCKET, SO_REUSEPORT, 1)` to `sock.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)`. I hope you get it right – AnaS Kayed Aug 30 '20 at 10:58
  • @AnaSKayed I'll give that a try and take a look at the question you've suggested. Thanks for the help, it's much appreciated. – Delroy Brown Aug 30 '20 at 11:02

0 Answers0