Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -6,7 +6,9 @@ import json
|
|
6 |
import os
|
7 |
import requests
|
8 |
from blockchain import Blockchain
|
9 |
-
from mychain import
|
|
|
|
|
10 |
from huggingface_hub import (create_repo,get_full_repo_name,upload_file,CommitOperationAdd,HfApi)
|
11 |
|
12 |
main_chain='https://huggingface.co/datasets/Omnibus/blockchain-sim/raw/main/chains/'
|
@@ -408,7 +410,7 @@ def get_my_chain_send(sender_name=None):
|
|
408 |
try:
|
409 |
r = requests.get(f'{main_balance}{sender_name}.json')
|
410 |
print (f'r={r.text}')
|
411 |
-
mychain_send =
|
412 |
response = {'chain': mychain_send.chain,
|
413 |
'length': len(mychain_send.chain)}
|
414 |
print (f'response={response}')
|
@@ -423,14 +425,14 @@ def get_my_chain_rec(recipient_name=None):
|
|
423 |
|
424 |
try:
|
425 |
r = requests.get(f'{main_balance}{recipient_name}.json')
|
426 |
-
mychain_rec =
|
427 |
response = {'chain': mychain_rec.chain,
|
428 |
'length': len(mychain_rec.chain)}
|
429 |
message = f"Blockchain loaded from: {main_balance}{recipient_name}.json"
|
430 |
return response,message
|
431 |
except Exception:
|
432 |
try:
|
433 |
-
mychain_rec =
|
434 |
response = mychain_rec.chain
|
435 |
message = f"Blockchain loaded from: {main_balance}{recipient_name}.json"
|
436 |
return response,message
|
|
|
6 |
import os
|
7 |
import requests
|
8 |
from blockchain import Blockchain
|
9 |
+
from mychain import MyChainSend
|
10 |
+
from mychain import MyChainRec
|
11 |
+
|
12 |
from huggingface_hub import (create_repo,get_full_repo_name,upload_file,CommitOperationAdd,HfApi)
|
13 |
|
14 |
main_chain='https://huggingface.co/datasets/Omnibus/blockchain-sim/raw/main/chains/'
|
|
|
410 |
try:
|
411 |
r = requests.get(f'{main_balance}{sender_name}.json')
|
412 |
print (f'r={r.text}')
|
413 |
+
mychain_send = MyChainSend(chain_load=main_balance,load=r.text)
|
414 |
response = {'chain': mychain_send.chain,
|
415 |
'length': len(mychain_send.chain)}
|
416 |
print (f'response={response}')
|
|
|
425 |
|
426 |
try:
|
427 |
r = requests.get(f'{main_balance}{recipient_name}.json')
|
428 |
+
mychain_rec = MyChainRec(chain_load=main_balance,load=r.text)
|
429 |
response = {'chain': mychain_rec.chain,
|
430 |
'length': len(mychain_rec.chain)}
|
431 |
message = f"Blockchain loaded from: {main_balance}{recipient_name}.json"
|
432 |
return response,message
|
433 |
except Exception:
|
434 |
try:
|
435 |
+
mychain_rec = MyChainRec(chain_load=main_balance,create=recipient_name)
|
436 |
response = mychain_rec.chain
|
437 |
message = f"Blockchain loaded from: {main_balance}{recipient_name}.json"
|
438 |
return response,message
|