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

Categories

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

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

1 Answer

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)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...