when the front end initiates a http request"/ getData", the project gets stuck
the index.py code is as follows:
from flask import Flask,render_template,request
import json
import pymssql
import urllib.parse
import sys
app = Flask(__name__)
@app.route("/")
def index():
return render_template("index.html")
@app.route("/hello")
def hello():
return "hello world"
@app.route("/getData",methods=["GET"])
def getddlData():
-sharp return json.dumps([])
sql="SELECT DISTINCT ChatRoomName FROM dbo.Issue"
conn=pymssql.connect(host="localhost", user="sa", password="123456", database="IssueCollect")
cursor=conn.cursor(as_dict=True)
cursor.execute(sql)
rooms=cursor.fetchall()
cursor.close()
conn.close()
return json.dumps(rooms)
if __name__ == "__main__":
app.run()
test.wsgi:
import sys
-sharpapp"s path
sys.path.insert(0,"C:/Users/Stephen/Desktop/IssueCollect")
from index import app
-sharpInitialize WSGI app object
application = app
Apache conf
LoadFile "c:/program files (x86)/python37-32/python37.dll"
LoadModule wsgi_module "c:/program files (x86)/python37-32/lib/site-packages/mod_wsgi/server/mod_wsgi.cp37-win32.pyd"
WSGIPythonHome "c:/program files (x86)/python37-32"
<VirtualHost *:5001>
WSGIScriptAlias / C:/Users/Stephen/Desktop/IssueCollect/test.wsgi
<Directory C:/Users/Stephen/Desktop/IssueCollect>
Require all granted
</Directory>
</VirtualHost>
close httpd, to check Apache error log: after being stuck
on Jul 23 14:05:52.534352 2018] [mpm_winnt:notice] [pid 3856:tid 600] AH00455: Apache/2.4.34 (Win32) mod_wsgi/4.6.4 Python/3.7 configured -- resuming normal operations
[Mon Jul 23 14:05:52.534853 2018] [mpm_winnt:notice] [pid 3856:tid 600] AH00456: Server built: Jul 10 2018 09:24:15
[Mon Jul 23 14:05:52.534853 2018] [core:notice] [pid 3856:tid 600] AH00094: Command line: "C:\\Apache24\\bin\\httpd.exe -d C:/Apache24"
[Mon Jul 23 14:05:52.536599 2018] [mpm_winnt:notice] [pid 3856:tid 600] AH00418: Parent: Created child process 18044
Apache server shutdown initiated...
pm_winnt:notice] [pid 18044:tid 712] AH00354: Child: Starting 512 worker threads.
[Mon Jul 23 14:06:58.522281 2018] [mpm_winnt:notice] [pid 3856:tid 600] AH00422: Parent: Received shutdown signal -- Shutting down the server.
[Mon Jul 23 14:07:30.572310 2018] [mpm_winnt:notice] [pid 18044:tid 712] AH00362: Child: Waiting 30 more seconds for 2 worker threads to finish.
[Mon Jul 23 14:08:00.692059 2018] [mpm_winnt:notice] [pid 18044:tid 712] AH00362: Child: Waiting 0 more seconds for 2 worker threads to finish.
[Mon Jul 23 14:08:00.792357 2018] [mpm_winnt:notice] [pid 18044:tid 712] AH00363: Child: Terminating 2 threads that failed to exit.
[Mon Jul 23 14:08:00.792357 2018] [mpm_winnt:notice] [pid 18044:tid 712] AH00364: Child: All worker threads have exited.
index.py access in the local python is normal,
is published to the Apache server, and empty data is returned directly without connecting to the database.
there is a problem connecting to the database. Is
my Apache configuration problem?