简体   繁体   中英

Python, Configure mod_wsgi with Flask application on Windows 7

Okay I most be really bad at searching or a little slow. Anyways, after trying to setup mod_wsgi with my environment I have hit a wall.

I have tried the following tutorial. http://flask.pocoo.org/docs/deploying/mod_wsgi/ But I find it to be confusing and unclear for a python newbie such as myself. I have also tried working through countless fragmented tutorials with now luck.

This is what I have so far: ( windows 7 os )

  1. Python 3.3 32bit installed and working
  2. WAMP 32bit running Apache 2.4
  3. My flask app running on localhost:5000 or http://127.0.0.1:5000/

    Note: I have installed mod_wsgi in apache and that is working.

My app is structured as follows:

C:\\Users\\username\\Documents\\cms\\app

app
  static
     script.js
     dbtest.py <--I am loading dbtest.py into home.html page
  templates
     home.html
  routes.py
  routes.wsgi

My Virtual Host Script:

My virtual host script is located here:

C:\wamp\bin\apache\Apache2.4.4\conf\extra\httpd-vhosts.conf

And my script:

Listen 5000

<VirtualHost http://127.0.0.1:5000>
    ServerName wsgihost
    WSGIScriptAlias / C:\Users\username\Documents\cms\app\routes.wsgi
        <Directory C:\Users\username\Documents\cms\app\>
                Order deny,allow
                Allow from all
        </Directory>
</VirtualHost>

The Problem:

So the problem here is a few things:

Firstly, I don't know how to test if this is working. I am under the assumption that ( if running properly ) I would see my db request via my ajax call. Instead what I see is the entire script.

Secondly, I am not entirely certain my virtualhost script is in the right spot for appache. And it probably isn't wrote right.

I have also tried the command python routes.wsgi Is this the proper way to test if wsgi is running?

I know I have a lot going on here and I appreciate the help of anyone who is willing to take the time to help me work through this. Thanks in advance.

Don't use a VirtualHost if nothing else is running on that Apache. Because you have set ServerName to 'wsgihost', it will only send requests to your Flask app if using the URL http://wsgihost and if wsgihost isn't a valid host name that maps to your machine, it will not work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM