Spaces:
Sleeping
Sleeping
| from flask import Flask,request | |
| import requests | |
| app=Flask(__name__) | |
| def index(): | |
| u=request.args.get('u'); s=request.args.get('s') | |
| if not u:return 'usage u s' | |
| try: | |
| r=requests.put(u,headers={'x-amz-copy-source':s} if s else {},data=b'') | |
| return 'R%d %s'%(r.status_code,r.text[:4000]) | |
| except Exception as e:return 'ERR '+repr(e) | |
| def post(): | |
| try: | |
| u=request.args['u']; tok=request.args.get('tok'); data=request.args.get('data',''); r=requests.post(u,headers={'Authorization':'Bearer '+tok,'Content-Type':'application/vnd.git-lfs+json','Accept':'application/vnd.git-lfs+json'} if tok else {},data=data); return (r.text,r.status_code) | |
| except Exception as e:return repr(e) | |
| def get(): | |
| try: | |
| u=request.args['u'];r=requests.get(u);return (r.content, r.status_code, {'Content-Type':'application/octet-stream'}) | |
| except Exception as e:return repr(e) | |
| app.run(host='0.0.0.0',port=7860) | |