ECMAScript Cookbook
上QQ阅读APP看书,第一时间看更新

How to do it...

  1. Check whether you have Python installed already.
  2. Open the command line.
  3. Enter the following command:
python --version
  1. If you see an output like the one displayed as follows, Python is already installed. And you can skip to step 6:
Python 2.7.10
  1. If you receive an error such as the following, continue with the installation in step 5:
command not found: python
  1. Install Python on your computer:
  2. Create a folder on your desktop named es8-cookbook-workspace.
  3. Inside the folder, create a text file named hello.txt and save some text to it.
  4. Open the Command Prompt and navigate to the folder:
  5.  In the Linux or macOS Terminal enter:
    cd ~/Desktop/es8-cookbook-workspace
  1. On Windows type the following command:
    cd C:Desktopes8-cookbook-workspace 
  1. Start the Python HTTP server with the following command:
    python -m SimpleHTTPServer # python 2 

Or we can use following command:

python -m http.server # python 3
  1. Open your browser and enter the following URL:
    http://localhost:8000/.
  1. You should see a page that shows the contents of the es8-cookbook-workspace folder:
  1. Click on the link to hello.txt and you'll see the text contents of the file you created.