简体   繁体   English

Python,在Windows 7上使用Flask应用程序配置mod_wsgi

[英]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. 无论如何,在尝试使用我的环境设置mod_wsgi ,我碰壁了。

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. http://flask.pocoo.org/docs/deploying/mod_wsgi/但对于像我这样的python新手,我感到困惑和不清楚。 I have also tried working through countless fragmented tutorials with now luck. 我也尝试过运气遍历无数分散的教程。

This is what I have so far: ( windows 7 os ) 这是我到目前为止所拥有的:( Windows 7 os

  1. Python 3.3 32bit installed and working Python 3.3 32位已安装并正常工作
  2. WAMP 32bit running Apache 2.4 运行Apache 2.4的WAMP 32bit
  3. My flask app running on localhost:5000 or http://127.0.0.1:5000/ 我的烧瓶应用程序在localhost:5000或http://127.0.0.1:5000/上运行

    Note: I have installed mod_wsgi in apache and that is working. 注意:我已经在apache中安装了mod_wsgi ,并且可以正常工作。

My app is structured as follows: 我的应用程序的结构如下:

C:\\Users\\username\\Documents\\cms\\app C:\\ Users \\用户名\\文档\\ CMS \\应用

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. 我假设( 如果运行正常 )我将通过我的ajax调用看到我的数据库请求。 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? 我也尝试过命令python routes.wsgi这是测试wsgi是否正在运行的正确方法吗?

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. 如果该Apache上没有其他任何运行,请不要使用VirtualHost。 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. 因为您已将ServerName设置为“ wsgihost”,所以只有在使用URL http://wsgihost ,并且wsgihost不是映射到您计算机的有效主机名时,它才会将请求发送到Flask应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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