Answer the question
In order to leave comments, you need to log in
How to send a picture to bottle and accept it via post request?
How can bottle in python3 respond to a post request with a picture and json information?
Right now I am sending and receiving json response like this
resp = post(
f'http://{ip}:5000/',
data=dumps({
"method": "some_method",
"arg1": arg1, "arg2": arg2
})
).json()
@route('/', method='POST')
def index():
ip = request.environ.get('REMOTE_ADDR')
if ip not in const.ACCESS_SERVERS:
return {"status": "ERROR", "response": {"respond": "not access", "code": "-4"}}
args = eval(request.body.getvalue().decode('utf-8'))
return {"status": "OK", "response": {"respond": "some respond", "code": "17"}}
run(host=curr_ip, port=5000)
Answer the question
In order to leave comments, you need to log in
In short, I solved the problem simply in two requests, separately returns json and separately bottle.static_file
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question