latnetnew / app.py
0Time's picture
init
0790a6d verified
Raw
History Blame Contribute Delete
724 Bytes
from flask import Flask,request,Response
import requests,json,base64
app=Flask(__name__)
@app.route('/')
def idx(): return 'ok'
@app.route('/go',methods=['GET','POST'])
def go():
try:
url=request.args.get('url');met=request.args.get('m','GET'); heads=json.loads(request.args.get('headers','{}')); body=request.get_data()
if request.args.get('body64'): body=base64.b64decode(request.args['body64'])
r=requests.request(met,url,headers=heads,data=body,timeout=180)
return Response(r.content,status=r.status_code,headers={'Content-Type':r.headers.get('Content-Type','text/plain'),'x-head':str(dict(r.headers))[:5000]})
except Exception as e:return repr(e),500
if __name__=='__main__':app.run(host='0.0.0.0',port=7860)