OS: Linux Debian (last build)
Python: 3.7.7 64bit
python: 3.8.2 64bit
Django: 3.0
Apache2: 2.4.x
[我正在尝试在Linux apache2(生产环境)上运行和测试我的Django项目。
我想通过pymysql
模块在数据库中插入一条记录(当用户输入的字符串正确/不正确(日志)时。)>
下面的函数(check_usr())在测试环境(127.0.0.1:8000)中工作正常。但不适用于生产。
我只是通过Web浏览器在validate()视图中看到else
部分的内容。
def check_usr (usernameee): result = subprocess.run(['........'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False) result = result.stdout.decode('utf-8') if "successfully" in result: return "ok" elif "activation failed" in result: return "no" else: return "problem" @require_http_methods(["GET"]) def validation(request): usernameee = request.GET["usernameee"] result = check_usr(usernameee) db_connection("init") if result == "ok": args = (ap_ssid, ap_mac, "ok") db_connection("INSERT INTO splash_tble (ap_ssid, ap_bssid, ap_state) VALUES (%s, %s, %s)", args) return render(request, "router/validation.html", {"validation_state": "success"}) elif result == "no": args = (ap_ssid, ap_mac, "no") db_connection("INSERT INTO splash_tble (ap_ssid, ap_bssid, ap_state) VALUES (%s, %s, %s)", args) return render(request, "router/validation.html", {"validation_state": "failed"}) else: return render(request, "router/validation.html", {"validation_state": "problem"})
/ etc / apache2 / sites-available / routers.conf中的我的配置:
DocumentRoot /root/PycharmProjects/router WSGIScriptAlias / /root/PycharmProjects/router/captives/wsgi.py WSGIPythonPath /root/PycharmProjects/router <Directory /root/PycharmProjects/router> <Files wsgi.py> Order deny,allow Allow from all Require all granted </Files> </Directory> Alias /static/ /root/PycharmProjects/router/captive_splash/static/ <Directory /root/PycharmProjects/router/captive_splash/static> Order deny,allow Allow from all Require all granted </Directory>
[请帮助我在Django中诊断和运行check_usr()函数。
OS:Linux Debian(最后构建)Python:3.7.7 64位python:3.8.2 64位Django:3.0 Apache2:2.4.x我正在尝试在Linux apache2(生产环境)上运行和测试我的Django项目。我想...
我确定问题出在routers.conf
文件中:(