satwikkansal / python_blockchain_app

A fully functional blockchain application implemented in Python from scratch (with tutorial).
819 stars 471 forks source link

404 returned when registering with another node #34

Closed hanglearning closed 4 years ago

hanglearning commented 4 years ago

First of all thanks satwikkansal for an awesome blockchain python tutorial!

When I tried to register a new node with an existing node by using these commands

$ flask run --port 8001

(in  a new terminal tab)$  curl -X POST \
  http://127.0.0.1:8001/register_with \
  -H 'Content-Type: application/json' \
  -d '{"node_address": "http://127.0.0.1:8000"}'

I got this returned back -

<title>404 Not Found</title>
<h1>Not Found</h1>
<p>The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.</p>

I checked the tab with port 8001, and I found port 8001 does receive this request, but also it shows a 404 error: 127.0.0.1 - - [31/Mar/2020 23:14:21] "POST /register_with HTTP/1.1" 404 -

Could anyone help me overcome this issue? Thanks!

satwikkansal commented 4 years ago

It seems like your port 8000 is running the application and not the node_server

hanglearning commented 4 years ago

Hi satwikkansal, thanks a lot for your reply!

No, I did run node_server on port 8000. I run the application on port 5000 by the default config. I didn't change any code and followed your tutorial blog. I just did these to reproduce the issue:

In my first tab, I run node_server on port 8000 Screen Shot 2020-04-02 at 11 38 41 AM

Then in my second tab, I run the app Screen Shot 2020-04-02 at 11 38 59 AM

In my third tab, I run another node_server on port 8001 Screen Shot 2020-04-02 at 11 39 06 AM

In my fourth tab, I tried to register 8001 with 8000 and got 404 Screen Shot 2020-04-02 at 11 39 26 AM

Come back to the third tab, there's an extra line showing 404 error as well Screen Shot 2020-04-02 at 11 39 37 AM

The first and second tabs didn't prompt any extra information.

Please let me know where I could do it wrong. I really appreciate your help! 😊

satwikkansal commented 4 years ago

You thrid tab is not serving node_server, compare the logs with the second tab.

You need to export the FLASK_APP environment variable in the third tab as well.

hanglearning commented 4 years ago

Oh correct! Thank you! Turns out it's my false assumption about how flask app runs! Sorry to bother you for this naive question.

Thanks again😁