启动代码如下:

    1. parser.add_argument('-p', '--port', default=8080, type=int, help='port to listen on')
    2. args = parser.parse_args()
    3. port = args.port
    4. app.run(debug=True,host='0.0.0.0',port=port)

    我们启动区块链

    访问全部区块:

    1. [
    2. {
    3. "data": "Genesis Block",
    4. "hash": "74eaf9085aa458f99c724583e4314b361bae60bff74e4cb82f89c9ecaa671406",
    5. "index": 0,
    6. "previous_hash": 0,
    7. "timestamp": 1533634910741
    8. },
    9. {
    10. "data": "hello",
    11. "hash": "41c28040287d26d66780f1175606fbf22d6a73c11355c64ae590b32d5e22d61b",
    12. "index": 1,
    13. "previous_hash": "74eaf9085aa458f99c724583e4314b361bae60bff74e4cb82f89c9ecaa671406",
    14. {
    15. "data": "hi~",
    16. "hash": "45aff7916c3410f9f93ac2a9dbcc24af33caa9120890ce0f1cabe02a3514b106",
    17. "index": 2,
    18. "previous_hash": "41c28040287d26d66780f1175606fbf22d6a73c11355c64ae590b32d5e22d61b",
    19. "timestamp": 1533634910741
    20. },
    21. {
    22. "data": "~",
    23. "hash": "cd3d295b8c2c168830e24132f58073f2d39cee95fa6ae4d87a8be248fe8eaf3f",
    24. "index": 3,
    25. "previous_hash": "45aff7916c3410f9f93ac2a9dbcc24af33caa9120890ce0f1cabe02a3514b106",
    26. "timestamp": 1533634910741
    27. }
    28. ]

    http://localhost:9090/blocks/last

    你能得到类似的结果:

    其中index就是区块链的高度

    访问index从1~3的区块

    你能得到类似的结果:

    1. [
    2. {
    3. "index": 1,
    4. "previous_hash": "d2c6ff3b8ab521d7837ac64873f7228d9f7e96ce727cec2a815d135545c65f44",
    5. "timestamp": 1533634461058
    6. },
    7. {
    8. "data": "hi~",
    9. "hash": "ad65bd6611bb84416766f231cfc87c86c885ad4f0a12bfa002c40119abd23b23",
    10. "index": 2,
    11. "previous_hash": "bbea6b876254a17d03cf154821be34be2ba782500da2b9310baa9d2f08567181",
    12. "timestamp": 1533634461058
    13. },
    14. {
    15. "data": "~",
    16. "hash": "b2bc5f8762252de051c06eccd2cadeda43a200f1e834e0033e056b341d0688d6",
    17. "index": 3,
    18. "previous_hash": "ad65bd6611bb84416766f231cfc87c86c885ad4f0a12bfa002c40119abd23b23",
    19. "timestamp": 1533634461058

    访问index为2的区块

    你能得到类似的结果: