Bottle中文教程:(一)安装

Tutorial

教程


This tutorial introduces you to the concepts and features of the Bottle web framework and covers basic and advanced topics alike. You can read it from start to end, or use it as a reference later on. The automatically generated API Reference may be interesting for you, too. It covers more details, but explains less than this tutorial. Solutions for the most common questions can be found in our Recipes collection or on the Frequently Asked Questionspage. If you need any help, join our mailing list or visit us in our IRC channel.

本教程会向你介绍 Bottle web框架的概念和功能,覆盖了一些基本和高级的主题。

你可以从头到尾通读,或是在以后用到时,当作参考手册。同时,你也许会对自动生成的API参考手册感兴趣。它覆盖了更多的细节,但没有本教程介绍的详细。很多大家都会遇到的问题,可以在回复列表或常问问题页面找到。如果你需要任何帮助,可以加入我们的邮件列表,或访问我们的IRC频道。


INSTALLATION

安装

Bottle does not depend on any external libraries. You can just download bottle.py into your project directory and start coding:

Bottle并不基于任何扩展的类库。只需要下载bottle.py文件到你的项目目录就可以使用它。

$ wget http://bottlepy.org/bottle.py

 

This will get you the latest development snapshot that includes all the new features. If you prefer a more stable environment, you should stick with the stable releases. These are available on PyPI and can be installed via pip (recommended), easy_install or your package manager:

你可以通过这条命令得到包含所有最新功能的开发版本。如果你希望在生产环境中使用,那就要选择稳定版。这些版本都被包含在PyPI中,可以通过pip,easy_install或者你的其它包管理器安装。

$ sudo pip install bottle              # recommended
$ sudo easy_install bottle             # alternative without pip
$ sudo apt-get install python-bottle   # works for debian, ubuntu, ...

Either way, you’ll need Python 2.5 or newer (including 3.x) to run bottle applications. If you do not have permissions to install packages system-wide or simply don’t want to, create avirtualenv first:

无论通过哪种方式安装,都需要Python 2.5 或 更新版本(包括 3.X)来运行bottle的应用。如果你没有权限安装系统级的软件包或只是不想安装,可以先创建一个virtualenv 

$ virtualenv develop              # Create virtual environment
$ source develop/bin/activate     # Change default python to virtual one
(develop)$ pip install -U bottle  # Install bottle to virtual environment

Or, if virtualenv is not installed on your system:

如果你的系统没有安装virtualenv,可以执行下面的命令安装:

$ wget https://raw.github.com/pypa/virtualenv/master/virtualenv.py
$ python virtualenv.py develop    # Create virtual environment
$ source develop/bin/activate     # Change default python to virtual one
(develop)$ pip install -U bottle  # Install bottle to virtual environment

 


posted @ 2013-08-05 21:10  呆头鱼  阅读(6880)  评论(0编辑  收藏  举报