我想用python Bottle框架为api创建一个示例应用程序,我还想在apache服务器上部署这个应用程序,我使用以下示例代码,

from bottle import route, run, template

@route('/hello/:name')
def index(name='World'):
    return template('<b>Hello {{name}}</b>!', name=name)

@route('/events/:id', method='GET')
def get_event(id):
    return dict(name = 'Event ' + str(id))
run(host='localhost', port=8082)

通过使用上述代码,我可以如何创建示例应用程序以及如何在服务器上部署该示例应用程序。如何才能做到这一点?

最佳答案

下面您将解释如何使用WSGI在apache中部署bottle应用程序:http://bottlepy.org/docs/dev/deployment.html#apache-mod-wsgi
就应用程序而言,您需要最佳的REST兼容,因此了解REST和瓶子,这里有一个很好的教程,我使用:http://myadventuresincoding.wordpress.com/2011/01/02/creating-a-rest-api-in-python-using-bottle-and-mongodb/

09-26 21:12
查看更多