0

I spent days now trying to deploy a Flask application (dash app precisely) in the Apache server on windows. I've followed the guidelines of so many resources, including :

I have Apache already installed under WAMPSERVER's stack package. Its path is:

C:\wamp64\bin\apache\apache2.4.39     

My python installation path :

C:\Python310     

My flask application dash_app.py is tested and works fine. It's running inside a virtual environment (viz_app). So, The structure of my app's folder is as follows :

--- dash_app 
            --- viz_app
            --- dash_app.py
            --- dash_app.wsgi
            --- requirements.txt
        

mod_wsgi is installed and configured using

pip install mod_wsgi    

After that, I created a file dash_app.wsgi to serve the Flask applications :

import os
import sys 

activate_this = 'C:/wamp64/model_control/dash_app/viz_app/Scripts/activate.py'
with open(activate_this) as file_:
    exec(file_.read(), dict(__file__=activate_this))

sys.path.insert(0, 'C:/wamp64/model_control/dash_app')
from dash_app import app as application

Next, I created a configuration file of my application :

<VirtualHost *:80>
    ServerName 192.168.250.50
    WSGIScriptAlias / C:/wamp64/model_control/dash_app/dash_app.wsgi
    <Directory C:/wamp64/model_control/dash_app>
         Require all granted
    </Directory>

    ErrorLog "C:/wamp64/logs/dash_app.error.log"
    CustomLog "C:/wamp64/logs/dash_app.access.log" common

</VirtualHost>

Next, I modified apache's configuration file (C:\wamp64\bin\apache\apache2.4.39\conf\httpd.conf ) to invoke the flask application by adding the following lines :

LoadFile "C:/Python310/python310.dll"
LoadModule wsgi_module "C:/Python310/lib/site-packages/mod_wsgi/server/mod_wsgi.cp310-win_amd64.pyd"
WSGIPythonHome "C:/Python310"

and these lines :

<Directory />
    AllowOverride none
    Require all granted
</Directory>

and finally these lines at the end of the file :

Include conf/dash_app.conf

I am stuck at this point, the application is still not deployed properly and I have no clue what I did wrong. Any guidance is appreciated.

P.S: I used WAMPSERVER because it's already installed in the machine and other applications of our ecosystem are deployed under it.

0 Answers0