satwikkansal / python_blockchain_app

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

Not able to execute the blockchain #32

Closed parul-k closed 4 years ago

parul-k commented 4 years ago

I have followed these steps to run project but I am not able to execute it:

Step 1: I have cloned the complete project from github.

Step 2: I am using windows 10 so I have opened command prompt and set: SET FLASK_APP=node_server.py flask run

After executing step 2: I see following message on the screen:

Step 3: When i am typing http://127.0.0.1:5000/ in browser it says:

Internal Server Error The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

When i checked the trace in command prompt, it says:

HTTPConnectionPool(host='127.0.0.1', port=8000): Max retries exceeded with url: /chain (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x03C0A4A8>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it')) 127.0.0.1 - - [25/Mar/2020 13:44:49] "GET / HTTP/1.1" 500 -

Kind help in this regard is highly appreciated.

satwikkansal commented 4 years ago

Please make sure env variable is set properly (see this)

And then make sure there's no other process running already on the same ports (5000 and 8000)

gerardkm94 commented 4 years ago

Looks like the APP is trying to reach /chain, but with port 8000... it's quite weir. At first, I recommend you to debug and try to catch the Exception when raised. If you can't, you can try to add this at the end of the server.py file:

if __name__ == '__main__': app.run(debug=True, port=8000)

And run into the terminal: python run_app.py instead of flask, and let's see what happens.

Set these variables as well,

            "FLASK_APP": "app.py",
            "FLASK_ENV": "development",
            "FLASK_DEBUG": "0"
parul-k commented 4 years ago

Looks like the APP is trying to reach /chain, but with port 8000... it's quite weir. At first, I recommend you to debug and try to catch the Exception when raised. If you can't, you can try to add this at the end of the server.py file:

if __name__ == '__main__': app.run(debug=True, port=8000)

And run into the terminal: python run_app.py instead of flask, and let's see what happens.

Set these variables as well,

            "FLASK_APP": "app.py",
            "FLASK_ENV": "development",
            "FLASK_DEBUG": "0"

Thanks for your kind response, I am able to see the following screen after running python run_app.py but its not doing anything, what about node_server.py !! Do I need to run that also? image

gerardkm94 commented 4 years ago

Yes, my mistake. Add if __name... to node_server.py and the, python node_server.py. Is not necessary to make python run_app.py.

parul-k commented 4 years ago

Yes, my mistake. Add if __name... to node_server.py and the, python node_server.py. Is not necessary to make python run_app.py.

if I am running, run_app.py with following code, from app import app app.run(debug=True) it displays:

requests.exceptions.ConnectionError requests.exceptions.ConnectionError: HTTPConnectionPool(host='127.0.0.1', port=8000): Max retries exceeded with url: /chain (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x041A8DA8>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it'))

but if run the same file with, from app import app app.run(debug=True, port=8000) I am able to see the following, what is happening I am not getting: YourNet: Decentralized content sharing......

parul-k commented 4 years ago

Modified node_server.py file and added: if name == 'main': app.run(debug=True, port=8000) but it is displaying the following:

image

satwikkansal commented 4 years ago

Your issue seems similar to https://github.com/satwikkansal/python_blockchain_app/issues/25

parul-k commented 4 years ago

Your issue seems similar to #25

You are right but I tried everything on referred page, still it says page not found.. This is why in my case run_app.py is running fine on port 5000 but node_server.py is saying 404 Not Found.. How to check whether flask is running node_server.py as a Server or web application, any suggestions ? This is what I am doing: image and result is image

satwikkansal commented 4 years ago

The web app is available at port 5000, not 8000. So this is expected behavior.

satwikkansal commented 4 years ago

Did you try running web app after this?

parul-k commented 4 years ago

The web app is available at port 5000, not 8000. So this is expected behavior.

Above code is for NODE SERVER

parul-k commented 4 years ago

Did you try running web app after this?

WEB APP is running fine

image

Problem is of NODE SERVER

satwikkansal commented 4 years ago

Did you create some test transactions using the web app? What error did you get?

parul-k commented 4 years ago

Did you create some test transactions using the web app? What error did you get?

Something worked finally, Instead of writing http://127.0.0.1:8000/ which is saying Page Not Found, I wrote: http://127.0.0.1:8000/mine It said nothing to mine http://127.0.0.1:5000/ opened and some text was entered http://127.0.0.1:8000/mine displayed: Block #1 is mined. After I clicked sync, it displayed my data.. This is how it was meant to be executed !!

satwikkansal commented 4 years ago

This is exactly what's written in the instructions here https://github.com/satwikkansal/python_blockchain_app#instructions-to-run

Anyways, closing the issue.

parul-k commented 4 years ago

This is exactly what's written in the instructions here https://github.com/satwikkansal/python_blockchain_app#instructions-to-run

Anyways, closing the issue.

Thanks a lot for your kind support ..