JSON-Array mit bottle zurückgeben - minimales Beispiel
Das Zurückgeben eines JSON-Arrays in bottle beinhaltet das Setzen des Response-Content-Types auf application/json und das manuelle Dumpen des Arrays mit json.dumps():
bottle_return_json.py
#!/usr/bin/env python3
from bottle import route, run, response
import json
@route('/')
def json_array():
response.content_type = 'application/json'
return json.dumps(["a", "b", "c"])
run(host='localhost', port=9000)Check out similar posts by category:
Python
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow