Code: Alles auswählen
def main():
with Path(filepath).open("rb") as fp:
image_binary = fp.read()
response = requests.post(
PINATA_BASE_URL + endpoint,
files={"file": (filename, image_binary)},
headers=headers,
)
ipfs_hash = response.json()["IpfsHash"]
print(response.json())
image_uri = "{}{}".format(first_part_image_uri, ipfs_hash)
print(image_uri)
# Aufruf Funktion create_image_uri_meta_file
simple_collectible = SimpleCollectible[len(SimpleCollectible) - 1]
token_id = simple_collectible.tokenCounter()
create_image_uri_meta_file(response, token_id)
return image_uri
Der bisher beste Versuch ist mir gelungen mit:
Code: Alles auswählen
from scripts.upload_to_pinata import main
image_uri = main()
image_uri_from_upload = image_uri
Hat jemand eine Lösung, Idee oder Vorschlag wie ich nur die eine Variable zwischen den Python-Skripten übertragen kann?
Hier ist noch ein Teil des Skripts indem die Variable eingefügt werden soll.
Code: Alles auswählen
#!/usr/bin/python3
from brownie import SimpleCollectible, accounts, network, config
from scripts.upload_to_pinata import main
# image_uri = main()
# image_uri_from_upload = image_uri
image_uri_from_upload = ""
def main():