In this section, we will go through a list of Git commands, which we will be using frequently throughout the book:
- git init: This command initializes your local repository once when you are setting it up for the first time
- git remote add origin <server>: This command links your local <indexentry content="Git command:git remote add origin " dbid="164250" state="mod">directory to the remote server repository so that all the changes pushed are saved in the remote repository
- git status: This command lists the files/directories that are yet to be added, or are modified and need to be committed
- git add * or git add <filename>: This command adds files/directories so that <indexentry content="Git command:git add * or git add " dbid="164250" state="mod">they can be tracked, and makes them ready to be committed
- git commit -m "Commit message": This command helps you commit your track changes in the local machine and generate the commit ID by which the updated code can be identified
- git commit -am "Commit message": The only difference between the previous command and this command is that this opens a default editor to add the commit message based on an operating system such as Ubuntu (Vim) or Windows (Notepad++) after adding all the files to stage
- git push origin master: This command pushes the last committed code from the local directory to the remote repository
Test everything to make sure our environment works.
Here we go. We have installed both Git and Python in the last section, which are needed to begin with building microservices. In this section, we will focus on testing the installed packages and try to get familiar with them.
The first thing we can do is to exercise the Git command, which fetches an external Python code from a repository (usually GitHub) over HTTPs, and copies it into our current workspace in the appropriate directory:
$ git clone https://github.com/PacktPublishing/Cloud-Native-
Python.git
The preceding command will create a directory named Cloud-Native-Python on your local machine; switch to the Cloud-Native-Python/chapter1 path from the current location.
We will need to install the requirements of the apps that are needed to run it. In this case, we just need the Flask module to be available:
$ cd hello.py
$ pip install requirements.txt
Here, Flask works as the web server; we will understand more about it in detail in the next chapter.
Once it is installed successfully, you can run the app using the following command:
$ python hello.py
* Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
I think we are good to see the output, which is as follows:
$ curl http://0.0.0.0:5000/
Hello World!
If you see this output, then our Python development environment is correctly set up.
Now it's time to write some Python code!