[Flask] Exposing bash commands over Rest API with Flask

Kelvin M kelvin.malyar at gmail.com
Sun Dec 3 11:30:54 EST 2017


Hi Sam,

It sounds like you're going part of the way in re-inventing the OpenAPI
specification for a Bash client.

A quick (and i mean cursory first response) glance shows this:
https://github.com/bkryza/bash-swagger-codegen

I would look into that:
https://swagger.io/blog/introducing-the-open-api-initiative/


Secondly, I'm not sure how Flask would help you implement bash commands
unless you're just running curl commands to different endpoints.  How does
that work?  It sounds interesting!

regards,
Kelvin

On Sun, Dec 3, 2017 at 11:12 AM, Shmulik Avramson <shmulikav at checkpoint.com>
wrote:

> Hi Flask community,
>
>
>
> I’m using Flask to expose exiting (propriety) shell commands over Rest
> API.
>
> Assuming I have “myCommand arg1 arg2 [arg3]” on my server,  I’m exposing
> new API as below:
>
>
>
> URL: https://<IP>/myCommand
> json:
>
> {
>
>                 "arg1":”<value>”,
>
>                 "arg2":”<value>”,
>
> "arg3":”<value>”
>
> }
>
>
>
> As I have many commands, I prepared an XML file to automate part of the
> process.
>
> The XML contains also validation for arguments and aggregate the API under
> features.
>
>
>
> An example:
>
>     <feature name="myFeature">
>
>       <commands>
>
>         <command url="/myCommand">
>
>           <must-args>
>
>             <arg key="arg1" type="boolean"/>
>
>             <arg key="arg2" type="int"/>
>
>           </must-args>
>
>           <opt-args>
>
>             <arg key="arg3" type="IP"/>
>
>           </opt-args>
>
>           <bash output="show/ignore"> myCommand {arg1} {arg2} {?arg3:arg3}
> </bash>
>
>         </command>
>
>       </commands>
>
>     </feature>
>
>
>
> Now, with the above infrastructure, every person in my company can easily
> expose his own bash commands.
>
>
>
> What do you think on the idea?
>
> Are there any similar functionalities in Flask I can use instead of
> developing my own?
>
> Assuming the answer is no, do you think it worth contribution?
>
>
>
> Thank in advance :)
>
> Sam
>
>
>
>
>
> _______________________________________________
> Flask mailing list
> Flask at python.org
> https://mail.python.org/mailman/listinfo/flask
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/flask/attachments/20171203/f23e9bab/attachment.html>


More information about the Flask mailing list