Implementation of a a python uWSGI server able to process an HTTP POST requests and get its JSON content
Linux, OSX: Run init.sh Windows. Native: TODO. Or use cygwin but don’t forget python-dev package.
The server will start:
~/ $ ./init.sh *** Starting uWSGI 2.0.18 (64bit) on [Fri Jun 5 21:12:24 2020] *** detected number of CPU cores: 4 current working directory: /Users/administrador/projects/delivery/server detected binary path: /Users/administrador/.local/bin/uwsgi !!! no internal routing support, rebuild with pcre support !!! your processes number limit is 1418 your memory page size is 4096 bytes detected max file descriptor number: 256 lock engine: OSX spinlocks thunder lock: disabled (you can enable it with --thunder-lock) uWSGI http bound on :9090 fd 4 uwsgi socket 0 bound to TCP address 127.0.0.1:57861 (port auto-assigned) fd 3 Python version: 3.8.2 (default, Jun 2 2020, 15:22:45) [Clang 10.0.1 (clang-1001.0.46.4)] *** Python threads support is disabled. You can enable it with --enable-threads *** Python main interpreter initialized at 0x7f9132f01330 your server socket listen backlog is limited to 100 connections your mercy for graceful operations on workers is 60 seconds mapped 145776 bytes (142 KB) for 1 cores *** Operational MODE: single process *** WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x7f9132f01330 pid: 9876 (default app) *** uWSGI is running in multiple interpreter mode *** spawned uWSGI master process (pid: 9876) spawned uWSGI worker 1 (pid: 9877, cores: 1) spawned uWSGI http 1 (pid: 9878)
This means the server is ready to process HTTP POST requests with Json as the content
You can use curl from the shell to test the server or any HTTP client using request.sh
. You will see the following:
~/projects/delivery/server (master)$ ./request.sh HTTP/1.1 200 OK Content-Type: application/json { "userId": juan-perez-id-001, "time":"Fri Jun 5 21:00:24 CDT 2020" }
-
The server answers with a JSON content and says everything is OK (HTTP/1.1 200 OK)
-
The HTTP request must honor the expected application path (
http://<server:port>/uwsgi-server/location
) -
A different application path will return
HTTP/404
-
Surround JSON property names with
"
or anHTTP/400
will return.