I am trying to deploy an API built on Django rest-framework using mod_wsgi and WAMP. When I created a new Django project using 'django-admin startproject Predictor' and deployed it on WAMP, it was working fine as I can see the default Django window.
Now I created an app in the project using 'python manage.py startapp Predictor' I built an API which accepts GET call and tested it using 'python manage.py runserver' and it was working fine. Now I started WAMP service again and try to go to 'localhost:8000' it keeps loading. And as soon as I stop WAMP service it crashes saying Unable to connect. Not sure what's happening. Can someone help what's wrong I am doing? FYI I am on windows and I have created and virtual environment for my Django project. This is how my .conf and wsgi files look like
wsgi_windows.py
activate_this = 'C:/Users/DELL/Envs/predenv/Scripts/activate_this.py'
# execfile(activate_this, dict(__file__=activate_this))
exec(open(activate_this).read(),dict(__file__=activate_this))
import os
import sys
import site
# Add the site-packages of the chosen virtualenv to work with
site.addsitedir('C:/Users/DELL/Envs/predenv/Lib/site-packages')
# Add the app's directory to the PYTHONPATH
sys.path.append('C:/Users/DELL/Envs/predenv')
sys.path.append('C:/Users/DELL/Envs/predenv/Predictor')
os.environ['DJANGO_SETTINGS_MODULE'] = 'Predictor.settings'
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "Predictor.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
httpd.conf
Listen localhost:8000
Listen [::0]:80
ServerName localhost:8000
LoadFile "c:/python376/python37.dll"
LoadModule wsgi_module "c:/python376/lib/site-packages/mod_wsgi/server/mod_wsgi.cp37-win_amd64.pyd"
WSGIPythonHome "c:/python376"
WSGIPythonPath "C:/Users/DELL/Envs/predenv/Predictor"
httpd-vhosts.conf
WSGIPythonPath "C:/Users/DELL/Envs/predenv/Predictor"
<VirtualHost *:80>
WSGIPassAuthorization On
ErrorLog "logs/predictor.error.log"
CustomLog "logs/predictor.access.log" combined
DocumentRoot "C:/Users/DELL/Envs/predenv/Predictor"
WSGIScriptAlias / "C:\Users\DELL\Envs\predenv\Predictor\Predictor\wsgi_windows.py"
<Directory "C:\Users\DELL\Envs\predenv\Predictor\Predictor">
<Files wsgi_windows.py>
Require all granted
</Files>
</Directory>
</VirtualHost>
The issue was it was not able to 'import pandas' in my views.py
To resolve this I have to add this line in my apache 'httpd-vhosts.conf' file
WSGIApplicationGroup %{GLOBAL}