运行Apache +瓶+的Python [英] running Apache + Bottle + Python

查看:121
本文介绍了运行Apache +瓶+的Python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好了,所以我试图用Bottle.py运行Python,直通Apache和mod_wsgi的,它不工作至今...

Ok so i'm trying to run Python with Bottle.py, thru Apache and mod_wsgi, and it doesn't work so far...

我运行在Windows上,使用XAMPP。蟒蛇V2.7

I'm running it on windows, using a xampp. python v2.7

在code I加入的httpd(Apache的配置):

the code i added to httpd(Apache config):

<VirtualHost *>
    ServerName example.com
    WSGIScriptAlias / C:\xampp\htdocs\GetXPathsProject\app.wsgi
    <Directory C:\xampp\htdocs\GetXPathsProject>
            Order deny,allow
            Allow from all
    </Directory>
</VirtualHost>

我app.wsgi code:

my app.wsgi code:

import os
os.chdir(os.path.dirname(__file__))
import bottle
application = bottle.default_app()

和我hello.py:

and my hello.py:

from bottle import route
@route('/hello')
def hello():
    return "Hello World!"

当我试图去到localhost

/你好,我得到一个404错误
我没有对Apache日志文件中的任何其他错误,可能失去了一些东西基本,会很乐意帮忙。

when i'm trying to go to localhost/hello i get an 404 error and i don't have any other error on the Apache log file, probably missing something basic, will be glad for help.

推荐答案

还有从您的 WSGI 文件到您的 hello.py 文件中没有连接点。

把内容在 hello.py app.wsgi 并重新启动Web服务器。

这应该解决这个问题。


为了使您的应用程序的模块化,这样你可以把code到各种文件,检查水瓶相当于蓝图(按瓶框架使用)的

There's no connecting point from your wsgi file to your hello.py file.
Put the content in your hello.py into the app.wsgi and restart your web server.
That should resolve the problem.

To make your application modular such that you can put the code into various files, check out Bottle's equivalent of Blueprints (used by Flask framework)

这篇关于运行Apache +瓶+的Python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆