I am using mod-wsgi with Apache 2.2
I have the following in WSGI script
import sys
sys.path.insert(0, '<path to my app>')
from optimization_app import optimizeInstances as application
and optimization_app.py
as follows:
from flask import Flask
from flask_restful import Api
from resources.Optimization import OptimizationAlgo
def optimizeInstances():
optimization_app = Flask(__name__)
api = Api(optimization_app)
api.add_resource(OptimizationAlgo, '/instances')
When I try to access the app url, I get the following in my apache error_log
TypeError: optimizeInstances() takes no arguments (2 given)
As I see u defined optimizeInstances() with No arguments. You might be calling optimizeInstances() function by passing 2 arguments to it.
This is occurring because you used it as the WSGI
application
object.A WSGI application is required to accept two parameters
environ
andstart_response
. So when the WSGI server is calling that function to have your application handle a request it is failing with that error.The way you are using that function is simply wrong. Your actual WSGI application is being created inside of that function in local scope, so how would it be accessed anyway.
Would suggest you check back and look at the Flask getting started documentation.