dvf / blockchain

A simple Blockchain in Python
MIT License
7.81k stars 2.75k forks source link

Internal error on calling /mine [GET] #176

Open pheu opened 4 years ago

pheu commented 4 years ago

I followed the instruction. Tried http://localhost:80/mine in postman.

> docker run --rm -p 80:5000 blockchain
 * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)

[2020-03-04 19:22:19,375] ERROR in app: Exception on /mine [GET]
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1982, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1614, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1517, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.6/site-packages/flask/_compat.py", line 33, in reraise
    raise value
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1612, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1598, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "blockchain.py", line 229, in mine
    return jsonify(response), 200
  File "/usr/local/lib/python3.6/site-packages/flask/json.py", line 251, in jsonify
    if current_app.config['JSONIFY_PRETTYPRINT_REGULAR'] and not request.is_xhr:
  File "/usr/local/lib/python3.6/site-packages/werkzeug/local.py", line 347, in __getattr__
    return getattr(self._get_current_object(), name)
AttributeError: 'Request' object has no attribute 'is_xhr'
172.17.0.1 - - [04/Mar/2020 19:22:19] "GET /mine HTTP/1.1" 500 -

System Windows 10, Docker version 2.2.0.3.

Btw. The strange thing is that it shows it's running on 0.0.0.0 instead of 127.0.0.1.

SwissRoll commented 4 years ago

It's no problem that it's running on 0.0.0.0, you can hit the endpoint at http://localhost:5000.

As for the error, Flask has a dependency that received a major version update somewhat recently. The easiest fix is to upgrade your version of Flask by running pip install --upgrade Flask.

Check out this stackoverflow answer for more details and a different solution: https://stackoverflow.com/a/60137731

mian24 commented 2 years ago

Is it resolved?

mian24 commented 2 years ago

My problem is similar to yours: image