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

 



免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM