unbit / uwsgi-docs

Official uWSGI docs, examples, tutorials, tips and tricks
MIT License
638 stars 348 forks source link

C and uWSGI #88

Open ghost opened 11 years ago

ghost commented 11 years ago

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?.

unbit commented 11 years ago

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...

ghost commented 11 years ago

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?

unbit commented 11 years ago

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

ghost commented 11 years ago

To request further information, do not bother again thank you

ruipacheco commented 10 years ago

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

Please do!

xrmx commented 8 years ago

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