import falcon
import json
class MainResource:
def on_get(self, req, resp):
resp.media = json.dumps({'status': 'success'})
api = falcon.API()
api.add_route('/', MainResource())
/api# gunicorn hand2:api
$ pip freeze
falcon==1.3.0
gunicorn==19.7.1
python-mimeparse==1.6.0
six==1.11.0
$ cat test.py
import falcon
import json
class MainResource:
def on_get(self, req, resp):
resp.media = json.dumps({'status': 'success'})
api = falcon.API()
api.add_route('/', MainResource())
$ gunicorn test:api
[2017-09-18 13:37:59 +0300] [11615] [INFO] Starting gunicorn 19.7.1
[2017-09-18 13:37:59 +0300] [11615] [INFO] Listening at: http://127.0.0.1:8000 (11615)
[2017-09-18 13:37:59 +0300] [11615] [INFO] Using worker: sync
[2017-09-18 13:37:59 +0300] [11618] [INFO] Booting worker with pid: 11618
$ curl 127.0.0.1:8000
"{\"status\": \"success\"}"
root@quad7:~/api# gunicorn hand2:api
[2017-09-18 14:31:21 +0300] [10904] [INFO] Starting gunicorn 19.7.1
[2017-09-18 14:31:21 +0300] [10904] [INFO] Listening at: http://127.0.0.1:8000 (10904)
[2017-09-18 14:31:21 +0300] [10904] [INFO] Using worker: sync
[2017-09-18 14:31:21 +0300] [10907] [INFO] Booting worker with pid: 10907
root@quad7:~# curl 127.0.0.1:8000
"{\"status\": \"success\"}"
yeger@mypc:~$ curl site.com:8000
curl: (7) Failed to connect to site.com port 8000: В соединении отказано
root@quad7:~# sudo ufw status
Status: active
To Action From
-- ------ ----
22 ALLOW Anywhere
#Как видите, порт 8000 разрешён
8000 ALLOW Anywhere
80 ALLOW Anywhere
81 ALLOW Anywhere
3306 ALLOW Anywhere
22 (v6) ALLOW Anywhere (v6)
8000 (v6) ALLOW Anywhere (v6)
80 (v6) ALLOW Anywhere (v6)
81 (v6) ALLOW Anywhere (v6)
3306 (v6) ALLOW Anywhere (v6)