0

wamp version : 2.5 , 64 bit
python version : 3.5.2 , 64 bit
windows version: 10 ,64 bit
apache version: 2.4.9
mod_wsgi: 4.4.23

I am trying to make python and flask work in wamp , so I read online and it says get wsgi which I did get from from here i put it in the apache modules file in this dir: C:\wamp\bin\apache\apache2.4.9\modules
I edited my httpd.conf file and added the following:

LoadModule wsgi_module modules/mod_wsgi.so 
WSGIPythonHome C:/Python35/ 

wamp was yellow in the begging but i figured it out all you had to do is stop the cgi module then instructions online say to make a virtual host so i did:

WSGIScriptAlias /flaskapp C:/wamp/www/flaskapp/flaskapp.wsgi<br>  
<VirtualHost *>
ServerName localhost
Directory C:/wamp/www/flaskapp>
Require all granted
</Directory>
</VirtualHost>

it also says to make a .wsgi so i made a file i called flaskapp.wsgi it contains :

import sys 
#Expand Python classes path with your app's path
sys.path.insert(0, 'C:/wamp/www/flaskapp')
from__init__ import app
#Put logging code (and imports) here ... 
#Initialize WSGI app object
application = app

after all this it should work normally but whenever I go to localhost/flaskapp/__init__.py I just get the same text in __init__.py which is :

from flask import Flask, request
app = Flask(__ name__) 
@app.route('/hello')
def hello_world():
 return "Hello World"
if __ name__ == '__ main__':
 app.run()

btw i have flask installed in my global env and python is set to work with all users and has access to PATH
i have tried everything so obviously something is wrong because its not working please if somebody knows help

  • Why are you trying to navigate to the python init script from the URL? You need to reverse proxy Apache to your Flask app – OneCricketeer Aug 13 '16 at 15:34
  • What? can you please explain what you just said? @cricket_007 – tryinghard Aug 13 '16 at 15:36
  • You stated... *whenever I go to localhost/flaskapp/`__init__.py` I just get the same text in `__init__.py`*. That isn't how you should connect to the server. You probably don't need a proxy, but it should just be `localhost/flaskapp` – OneCricketeer Aug 13 '16 at 15:40
  • when i do that i just get an index of the flaskapp dir it shows me all the files in flaskapp @cricket_007 – tryinghard Aug 13 '16 at 15:44
  • Possible duplicate of [Flask hello world using apache and mod\_wsgi shows files in webroot only](http://stackoverflow.com/questions/21084791/flask-hello-world-using-apache-and-mod-wsgi-shows-files-in-webroot-only) – OneCricketeer Aug 13 '16 at 15:54
  • well @cricket_007 that solution didnt work for me, that solution only adds WSGIProcessGroup `__init__` WSGIApplicationGroup %{GLOBAL} to the vhost which does nothing – tryinghard Aug 13 '16 at 17:35
  • I'm not entirely sure, then, but somehow the `mod_wsgi` isn't working and Apache is simply serving that directory's files – OneCricketeer Aug 13 '16 at 19:48
  • 1
    FIGURED IT OUT @cricket_007 so basicaly i disabled cgi , because when i put wsgi wamp was yellow so when i disabled cgi wamp became green so i thought cgi was the problem , now i was giving up so i said lets return everything to how it was i turned on cgi and wamp went yellow then #green ` I DONT KNOW WHY` after that everything worked fine – tryinghard Aug 13 '16 at 20:01
  • Awesome. You're welcome to answer your own posts below – OneCricketeer Aug 13 '16 at 20:06
  • @cricket_007 When using mod_wsgi you don't set Apache up as a proxy. If you were going to use Apache as a proxy to separate Flask application then you wouldn't need mod_wsgi in the first place. You also cannot use daemon mode of mod_wsgi as it isn't supported on Windows. As to removing mod_cgi, that should really have been necessary, so bit odd. – Graham Dumpleton Aug 13 '16 at 20:44
  • Whoops, meant 'that should not really have been necessary'. – Graham Dumpleton Aug 14 '16 at 04:09

1 Answers1

0

So basicaly i disabled cgi , because when i put wsgi wamp was yellow so when i disabled cgi wamp became green so i thought cgi was the problem , now i was giving up so i said lets return everything to how it was i turned on cgi and wamp went yellow then

GREEN

I DONT KNOW WHY after that everything worked fine
THANKS FOR ANYONE WHO TRIED TO HELP ME :)

Community
  • 1
  • 1