I have deployed a Flask app(REST API) on Apache server. The Apache server is part of the WAMP setup. Its a windows 10 machine. When I run the flask app using flask server, I can bind it to any port and it works. But when I try to use it from mod_wsgi, I get the error
OSError: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions
Apache is running on port no 5000. I was expecting flask app to use the same port and execute the python code. What am I doing wrong.
In the virtual host config is given below
<VirtualHost *:5000>
DocumentRoot "${INSTALL_DIR}/www/AppDir/"
Alias /CourseReco/ "${INSTALL_DIR}/www/AppDir/"
<Directory "${INSTALL_DIR}/www/AppDir/">
Allow from all
Require all granted
Options Indexes Includes ExecCGI FollowSymLinks
AllowOverride None
Order deny,allow
DirectoryIndex index.cgi index.html index.py
AddHandler cgi-script .py
</Directory>
The app_API.wsgi file is
#!d:/development/anaconda/envs/app_api/python.exe
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"C:\wamp64\www\AppDir")
from app_API import app as application
The app_API.py file looks like this. The answer from this question has been used to instantiate another class
Object Oriented Python with Flask Server?
from flask import Flask, jsonify, request
from apilogic import apilogic
import logging
logging.basicConfig(filename='example.log',level=logging.DEBUG)
import os
class app_API:
applogic= apilogic() #I want to load data once and not for every API call so doing this
from flask import Flask, jsonify, request
app = Flask(__name__)
@app.route("/getData")
def GetData():
input=request.args.get('arg1')
return app_API().applogic.send_data(input)
if __name__ == "__main__":
app.run()
What is it that I am doing wrong? Any help is appreciated. Thanks