Simple, concise HTTP endpoint app development in C or C++?

Discussion in 'C++' started by stackoverflowuser95@gmail.com, Nov 10, 2013.

  1. Guest

    I want to create a very simple set of HTTP endpoints in C or preferably C++.

    Can you recommend a library/toolkit/framework providing similar conciseness of expression to this simple Python (Bottle) project?

    from bottle import get, post, static_file, response, run

    @get('/scripts')
    def get_scripts():
    # add code here to tar scripts folder(s)
    return static_file("scripts.tar.xz", root='/path/to/scripts',
    download="scripts.tar.xz")

    @post('/scripts/new/<filename>')
    def post_new_script(filename):
    try:
    # add code here to delete if exist then "post"/create script
    except ValueError:
    response.status = 400
    return dict(error="Value error on script post")
    # ^-- This is returned as JSON

    if __name__ == '__main__':
    run(host='localhost', port=8080) # Serve on a small web-server
     
    , Nov 10, 2013
    #1
    1. Advertising

  2. Jorgen Grahn Guest

    On Sun, 2013-11-10, wrote:
    > I want to create a very simple set of HTTP endpoints in C or preferably C++.


    Do you mean a HTTP server? "Endpoint" sounds like "client or server
    (but not proxy)".

    > Can you recommend a library/toolkit/framework providing similar
    > conciseness of expression to this simple Python (Bottle) project?


    Sorry, no. I guess what people usually do is to choose a web server
    (Apache, Nginx, ...) and extend them using their defined mechanisms.
    Is there a reason you don't want to do that?

    /Jorgen

    --
    // Jorgen Grahn <grahn@ Oo o. . .
    \X/ snipabacken.se> O o .
     
    Jorgen Grahn, Nov 10, 2013
    #2
    1. Advertising

  3. On 10.11.2013 08:00, wrote:
    > I want to create a very simple set of HTTP endpoints in C or preferably C++.


    In order to get good answers I recommend that you define the terminology
    you employ, e.g. what's meant by "endpoint".


    > Can you recommend a library/toolkit/framework providing similar conciseness
    > of expression to this simple Python (Bottle) project?


    The code that you quote below does NOT illustrate any conciseness, since
    it doesn't do anything application-specific.

    On the contrary, it illustrates the opposite of conciseness.

    Running a server with defaults for everything should not be more than a
    single call "start_server()".


    >
    > from bottle import get, post, static_file, response, run
    >
    > @get('/scripts')
    > def get_scripts():
    > # add code here to tar scripts folder(s)
    > return static_file("scripts.tar.xz", root='/path/to/scripts',
    > download="scripts.tar.xz")
    >
    > @post('/scripts/new/<filename>')
    > def post_new_script(filename):
    > try:
    > # add code here to delete if exist then "post"/create script
    > except ValueError:
    > response.status = 400
    > return dict(error="Value error on script post")
    > # ^-- This is returned as JSON
    >
    > if __name__ == '__main__':
    > run(host='localhost', port=8080) # Serve on a small web-server


    Presumably you have some reason for not using e.g. Apache server, as
    suggested elsewhere in this thread. Then I would check out the list of
    C++ libraries posted to this group and to clc++m monthly.

    Also, Internet search engines such as AltaVista (or the newfangled so
    called "Google") can find such libraries for you, in just uno zwei drei.

    If, contrary to expectation, you fail to find such a library, then do
    check out the Python bindings available in e.g. the Boost library.

    Then, worst case, you can just use the Python library from C++.

    Good luck! :)


    Cheers & hth.,

    - Alf
     
    Alf P. Steinbach, Nov 10, 2013
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. darrel
    Replies:
    13
    Views:
    810
    darrel
    Mar 30, 2006
  2. Lincoln Cooper

    Web Services endpoint development

    Lincoln Cooper, Feb 10, 2004, in forum: Java
    Replies:
    2
    Views:
    384
    Lincoln Cooper
    Feb 11, 2004
  3. Replies:
    0
    Views:
    422
  4. Frohnhofer, James

    Concise idiom to initialize dictionaries

    Frohnhofer, James, Nov 9, 2004, in forum: Python
    Replies:
    8
    Views:
    347
    Caleb Hattingh
    Nov 12, 2004
  5. pbd22
    Replies:
    1
    Views:
    766
    pbd22
    Jul 22, 2009
Loading...

Share This Page