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

  • Thread starter stackoverflowuser95
  • Start date
S

stackoverflowuser95

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
 
J

Jorgen Grahn

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
 
A

Alf P. Steinbach

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top