小编sas*_*shk的帖子

如何用py.test monkeypatch python的datetime.datetime.now?

我需要测试使用的功能datetime.datetime.now().最简单的方法是什么?

python datetime mocking pytest

23
推荐指数
5
解决办法
8490
查看次数

nginx uwsgi和cgi python脚本

我遇到了问题.我有一个python脚本.你可以称之为CGI脚本.它在Apache2下工作正常,但在关闭系统之前只剩下一个它永远运行.新系统使用nginx.我按照许多人的建议配置uwsgi,同时搜索解决方案,配置虚拟主机以运行此脚本.我在uwsgi wiki上使用了第一个例子来确认我已经正确配置了nginx,它可以与uwsgi进行通信.像魅力一样工作.

现在我的并发症:

我的脚本是前一段时间编写的,不是为WSGI设计的,我也不想/可以重写它.

所以我已经为uwsgi安装了cgi模块并尝试使用它.我得到的只是502错误.什么都没有执行uwsgi.

这是我用于此应用程序的配置:

[uwsgi]
plugins = cgi
socket = 127.0.0.1:9010
cgi = /=/usr/share/test/
cgi-allowed-ext = .py
cgi-helper = .py=python
Run Code Online (Sandbox Code Playgroud)

这是我在index.py(测试脚本)中的代码:

#!/usr/bin/python
print "Content-type: text/html\n\n"
print "<html><body><h1>It works!</h1></body></html>"
Run Code Online (Sandbox Code Playgroud)

我尝试使用以下命令测试uwsgi:

/usr/sbin/uwsgi --http :9011 --ini /etc/uwsgi/test.ini --master
Run Code Online (Sandbox Code Playgroud)

这是我得到的输出:

[uWSGI] getting INI configuration from /etc/uwsgi/test.ini
*** Starting uWSGI 1.1.2 (64bit) on [Fri Apr 20 15:26:33 2012] ***
compiled with version: 4.4.6 20110731 (Red Hat 4.4.6-3) on 19 April 2012 15:09:37
current working directory: /home/user
detected binary path: /usr/sbin/uwsgi
your …
Run Code Online (Sandbox Code Playgroud)

python cgi nginx uwsgi

5
推荐指数
1
解决办法
5947
查看次数

标签 统计

python ×2

cgi ×1

datetime ×1

mocking ×1

nginx ×1

pytest ×1

uwsgi ×1