Я создал очень маленький сайт с python, uwsgi и nginx. Когда я набираю localhost:8080
в строке адреса веб-браузера, отображается что-то вроде «hello world».Получить строку запроса в nginx и веб-сайте uwsgi
Далее я собираюсь добавить обработку строки запроса, но не знаю, как это сделать. Я хотел бы, чтобы строка запроса печаталась в командной строке, например. Таким образом, адрес будет таким, как localhost:8080?abc&id=21&price=778
, и строка запроса вроде этого abc&id=21&price=778
Я не могу добиться успеха. Здесь вы выход и коды:
(myappenv) [email protected]:~/Dropbox/PycharmProjects/digitalOApp$ uwsgi --ini digitalOApp.ini
[uWSGI] getting INI configuration from digitalOApp.ini
*** Starting uWSGI 2.0.14 (64bit) on [Mon Feb 6 04:54:51 2017] ***
compiled with version: 4.9.2 on 03 February 2017 02:52:59
os: Linux-3.16.0-4-amd64 #1 SMP Debian 3.16.39-1 (2016-12-30)
nodename: localhost
machine: x86_64
clock source: unix
detected number of CPU cores: 2
current working directory: /home/gameboy/Dropbox/PycharmProjects/digitalOApp
detected binary path: /home/gameboy/Dropbox/PycharmProjects/digitalOApp/myappenv/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
your processes number limit is 15353
your memory page size is 4096 bytes
detected max file descriptor number: 65536
lock engine: pthread robust mutexes
thunder lock: enabled
uwsgi socket 0 bound to UNIX address /home/gameboy/Dropbox/PycharmProjects/digitalOApp/digitalOApp.sock fd 3
uwsgi socket 1 bound to TCP address :8080 fd 4
Python version: 3.4.2 (default, Oct 8 2014, 10:47:48) [GCC 4.9.1]
Python main interpreter initialized at 0x17461e0
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 436608 bytes (426 KB) for 5 cores
*** Operational MODE: preforking ***
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x17461e0 pid: 14147 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 14147)
spawned uWSGI worker 1 (pid: 14148, cores: 1)
spawned uWSGI worker 2 (pid: 14149, cores: 1)
spawned uWSGI worker 3 (pid: 14150, cores: 1)
spawned uWSGI worker 4 (pid: 14151, cores: 1)
spawned uWSGI worker 5 (pid: 14152, cores: 1)
None
[pid: 14148|app: 0|req: 1/1] 127.0.0.1() {36 vars in 646 bytes} [Mon Feb 6 04:55:14 2017] GET /?a=hej => generated 41 bytes in 0 msecs (HTTP/1.1 200) 1 headers in 44 bytes (0 switches on core 0)
None
[pid: 14151|app: 0|req: 1/2] 127.0.0.1() {36 vars in 620 bytes} [Mon Feb 6 04:55:16 2017] GET /favicon.ico => generated 41 bytes in 0 msecs (HTTP/1.1 200) 1 headers in 44 bytes (0 switches on core 0)
wsgi.py:
import os, sys
def application(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/html')])
print(os.getenv("QUERY_STRING"))
h1 = "<h1 style='color:blue'>Hello There!</h1>"
return(bytes(h1, 'utf-8'))
digitalOApp.ini:
[uwsgi]
module = wsgi:application
master = true
processes = 5
socket = /home/gameboy/Dropbox/PycharmProjects/digitalOApp/digitalOApp.sock
chmod-socket = 664
vacuum = true
die-on-term = true
enable-threads = true
thunder-lock = true
socket = :8080
protocol = http
Nginx:
(myappenv) [email protected]:~/Dropbox/PycharmProjects/digitalOApp$ sudo cat /etc/nginx/sites-enabled/digitalOApp
[sudo] password for gameboy:
server {
listen 80;
server_name localhost;
location/{
include uwsgi_params;
uwsgi_pass unix:/home/gameboy/Dropbox/PycharmProjects/digitalOApp/digitalOApp.sock;
}
}
(myappenv) [email protected]:~/Dropbox/PycharmProjects/digitalOApp$