Bottle Developer Chinese Document (2)--Quick Start "Hello world!"

Source: Internet
Author: User

Quick Start "Hello world!"

This tutorial assumes that you have installed bottle or have copied it to your project directory. Let's take a look at this very basic example of "helloWorld":

 from Import route, Run@route ('/hello') def Hello ():     return " Hello world! " Run (Host='localhost', port=8080, Debug=true)

Run this script, Access Http://localhost:8080/hello then you can see "Hello World" in your traffic, here's how he works:

route ()   modifier in URL /hello path to access hello ()   function. It is called a route ( ) Span style= "font-family: the song Body;" > This is the most important concept in this framework. You want to define how much routes You can define how much. When a browser goes to request a url The associated function is called and the return value is sent to a browser. It's so simple!

Run () is called on the last line to start a built-in development server. The server runs on the 8080 port on localhost and accepts the request until it is stopped using Ctrl + C . You can replace the backend server later, but now this development server is enough for us to use. It does not need to be installed at all and can be very laborious for your program to start running for local testing.

  Debug mode is useful in the early stages of development, but remember to turn off debug mode when you publish your program .

This is a very simple procedure, of course, and he shows a basic concept of how to build a program on bottle. Read on and you'll see more of the other possibilities.

If there is any fallacy please point out, thank you! We learn together, reproduced the source of the specified!

Bottle Developer Chinese Document (2)--Quick Start "Hello world!"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.