Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
820 views
in Technique[技术] by (71.8m points)

running Apache + Bottle + Python

I'm trying to run Bottle.py with Apache and mod_wsgi.

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

My Apache config in httpd:

<VirtualHost *>
    ServerName example.com
    WSGIScriptAlias / C:xampphtdocsGetXPathsProjectapp.wsgi
    <Directory C:xampphtdocsGetXPathsProject>
            Order deny,allow
            Allow from all
    </Directory>
</VirtualHost>

My app.wsgi code:

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

My hello.py:

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

When I go to localhost/hello I get a 404 error. I don't have any other errors on the Apache log file, probably missing something basic.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...