官术网_书友最值得收藏!

Setting up the environment

The first thing we have to do is, as usual, set up our development environment and the first step is to create a virtual environment for our application. Our application will be called twittervotes, so let's go ahead and create a virtual environment called twittervotes:

When the virtualenv environment has been created, you can activate it with the following command:

. twittervotes/bin/activate

Great! Now let's set up the project's directory structure. It should look like the following:

twittervotes
├── core
│ ├── models
│ └── twitter
└── templates

Let's dive into the structure a bit:

Next, it is time to add our project's dependencies. Go ahead and create a file called requirements.txt in the twittervotes directory with the following content:

Flask==0.12.2
oauth2==1.9.0.post1
PyYAML==3.12
requests==2.18.4
Rx==1.6.0

The following table explains what the preceding dependencies mean:

When the file has been created, run the command pip install -r requirements.txt, and you should see an output similar to the following:

If you run the command pip freeze, you will get a list of dependencies in pip format and you will notice that the output lists more dependencies that we actually added to the requirements file. The reason for that is that the packages that our project requires also have dependencies and they will also be installed. So do not worry if you have more packages installed than you specified in your requirements file.

Now that our environment is set up, we can start creating our Twitter application. As usual, before you start coding, make sure that you have your code under a source control system such as Git; there are plenty of online services that will host your repositories for free.

In this way, you can roll back different versions of your projects and you don't have the risk of losing your work if you have problems with your computers. With that said, let's create our Twitter application.

主站蜘蛛池模板: 井冈山市| 铁岭市| 九江县| 齐齐哈尔市| 绵阳市| 河东区| 二连浩特市| 安庆市| 承德县| 博罗县| 额敏县| 通海县| 文水县| 无极县| 容城县| 高尔夫| 济南市| 山东| 浪卡子县| 望谟县| 麻城市| 瑞安市| 当涂县| 城市| 黄平县| 吉安市| 赣州市| 阿鲁科尔沁旗| 祁门县| 苏尼特左旗| 轮台县| 区。| 通河县| 雷山县| 池州市| 碌曲县| 嘉定区| 凤庆县| 康平县| 永川市| 涞源县|