eshaan7 / Flask-Shell2HTTP

Execute shell commands via HTTP server (via flask's endpoints).
https://flask-shell2http.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
170 stars 28 forks source link

Force Option and Result URL #25

Closed madhavajay closed 2 years ago

madhavajay commented 2 years ago

It would be great to make the calls idempotent to some degree so that if you call it twice you can still follow the result without having to manually reconstruct the correct result url.

The error JSON could have the correct result_url so you don't need to construct it.

Failed to get result {'error': 'future_key 2ea86600 already exists'}

There could be an option during call to ignore if theres an existing entry and overwrite it?

BTW awesome lib, this was exactly what I was looking for. 🤗

eshaan7 commented 2 years ago

Hey, @madhavajay. If I understand correctly,

{'error': 'future_key 9ab93181 already exists', 'key': '9ab93181', 'result_url': 'http://localhost/cmd/echo?key=9ab93181'}

This as an example is what you are looking for, right ?

eshaan7 commented 2 years ago

There could be an option during call to ignore if theres an existing entry and overwrite it?

While there is no option to overwrite an existing entry, there is another option (force_unique_key) that allows you to always have a unique entry. Add the force_unique_key attribute in the POST request for this. Example: {"args": ["hello", "world"], "force_unique_key": true}.

See the "Hint" card in this section of the docs for more info.

eshaan7 commented 2 years ago

This has been included in the v1.7.0 release.