uwsgi-docs icon indicating copy to clipboard operation
uwsgi-docs copied to clipboard

C and uWSGI

Open ghost opened this issue 12 years ago • 6 comments

hi,

uWSGI can be used with the C programming language?

Sample C

#include <stdio.h>

int main ()
{
     printf ("Hello World");
}

Do I have to transfer the output to the web with uwsgi?.

ghost avatar Sep 12 '13 08:09 ghost

If you mean as CGI, just check the CGI plugin documentation.

If you want to embed, the default build profile automatically includes the "symcall" plugin:

#include <uwsgi.h>

int myhandler(struct wsgi_request *wsgi_req) {
    uwsgi_response_write_body_do(wsgi_req, "Hello World", 11);
    return UWSGI_OK;
}

build it as a shared library

and load and map it (binding to port 8080):

uwsgi --dlopen ./yourlib.so --symcall myhandler --http-socket :8080 --http-socket-modifier1 18

You may want to check the cplusplus too example plugin in the plugins directory

The uWSGI C api is pretty big, but allows you to easily manage things like QUERY_STRING, cookies, uploads and so on...

unbit avatar Sep 12 '13 08:09 unbit

Thank you,

Do you think I'm developing my website on the basis of C and the right to use uWSGI will you?

Is there a more detailed documentation on how to use C to uWSGI?

ghost avatar Sep 12 '13 13:09 ghost

In my company we heavily use it with C apps (we basically abstracted all of the web layers so we can focus on heavy logic). The vast majority of the available plugins are the result of those C apps. So defintely i recommend it.

The problem is that there are few docs about the api, but it is stable by 2 years, and you can check the plugins for basically every example.

In addition to this, you get multiprotocol and different concurrency models for free.

I can create a C_Api.rst page in which to collect the various functions.

Feel free to ask for more infos

unbit avatar Sep 12 '13 13:09 unbit

To request further information, do not bother again thank you

ghost avatar Sep 12 '13 14:09 ghost

I can create a C_Api.rst page in which to collect the various functions.

Please do!

ruipacheco avatar Apr 16 '14 21:04 ruipacheco

Recent thread with some hints: http://lists.unbit.it/pipermail/uwsgi/2015-October/008210.html

xrmx avatar Oct 31 '15 14:10 xrmx