Skip to content

Commit

Permalink
test python scripts
Browse files Browse the repository at this point in the history
test python scripts put and get file form ipfs
  • Loading branch information
asdg-asdf authored Mar 29, 2019
1 parent 19cf126 commit 269de7c
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions py-ipfs-api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/env python
# python2.7.16

import ipfsapi
import sys


def main():
if len(sys.argv) < 3 :
print "args error\nUsage: ./py-ipfs-api.py ${ipaddress} add gettestfile.py"
sys.exit(1)

if sys.argv[2] == "get" :
api = ipfsapi.connect(sys.argv[1], 5001)
for file in sys.argv[3:] :
res = api.get(file)
print res

if sys.argv[2] == "add" :
api = ipfsapi.connect(sys.argv[1], 5001)
for file in sys.argv[3:] :
res = api.add(file)
print res

if __name__ == "__main__":
main()

0 comments on commit 269de7c

Please sign in to comment.