I am running a Dockercontainer. My Falcon app.py looks like:
import falcon
class Workers:
def on_post(self, expedice, celkem_pracovniku, req, resp):
output = str(
{
"expedice": expedice,
"celkem_pracovniku": celkem_pracovniku
}
)
resp.text = output
resp.status = falcon.HTTP_OK
app = application = falcon.API()
app.add_route("/pozice_skladApi/v1/pracovnici", Workers())
I am running a docker image on port 8082:80, but I dont now how can I run the /pozice_skladApi/v1/pracovnici exactly. I try:
curl -X POST http://localhost:8082/pozice_skladApi/v1/pracovnici -d "knihy-praha" 10 but I got {"title": "500 Internal Server Error"}. What I do wrong, please?
The problem was in the
on_postfunction. Correct form is:Then you can use following command in the terminal:
curl -X POST -H "Content-Type: application/json" -d '{"expedice": "knihy-praha", "celkem_pracovniku": 10}' http://localhost:8082/pozice_skladApi/v1/pracovnici