How to build a Web site (i)

Source: Internet
Author: User

Objective:

As the new student military training ended, as a student union technical Department of the old fritters, this time to help them.

Most of the freshmen are running to do some small things, can be used by everyone else, for the purpose of entering the technical department, the Department is mainly responsible for the operation of departments, incidentally do development. The first two write the front end, a write back end (PHP), I write Golang. Based on the ability to bring a group of people in the college, to train everyone team cooperation ability, for the future to build a team to provide a good network for the purpose, feel that the Department of technical Department still have reason to exist. Because the first two, is a person in the department to do things, and then to the Web-based, not in-depth understanding of the bottom, I learn the bottom is not very good, is now trying to fill. Today the department is dominated by Golang, and Java is the school-leading curriculum. Words don't say much.

First of all: to build a Web site, we need to understand its rationale: simply (in terms of user) is the browser request a domain name, and then get a page of the whole process.

The specific details are ():

And the data flow is as follows:

I believe we are very familiar with it. And this is the details of what we learn in the computer network, all kinds of head, agreement ah and so on.

In the general understanding of the entire web process, we will talk about the server, database.

Usually everyone is in their own computer programming, here we are talking about the web, then how to run a Web service in this machine, first we have to open a Web service, with Apache or nginx, or use the program to write a Web service, and then this Web service corresponding port set, Once the service is turned on (I turn on port 80), you will be able to request 127.0.0.1:80 in your browser and respond accordingly to your native Web service.

Here I use Golang to write a simple service open port, request the corresponding URL can respond. such as (this is a simple request) may differ in the syntax of each language but the corresponding thought is the same

Yes, that's right. This is a simple service, of course, under the same LAN, others through the IP access to the corresponding port is also able to achieve the effect.

Some people say how do I make the page show what I want. We can see this test method, the test method has request and response, yes, accept the user request, of course you have to return a thing to the user. This time you can tell the user an HTML page or other.

Let's try to return a Hello world to the user

I'm so happy we saw our long-lost hello world. We observed that we cast the string to byte type, which is required because the underlying TCP stream is streamed in a byte stream.

is not very simple.

For the application layer, now has a company to write these services, we just use it, nginx Ah, Apache AH. So we just need to configure Apache or Nginx to be good.  Then point to the corresponding file directory, or through them proxy to our server, the implementation of this data operation. The ultimate goal is to return the data to the client.

Said so much, no matter how to write, if there are technical errors in the text, welcome to discuss, amend, hope to be able to express their understanding, do not like to spray.

How to build a Web site (i)

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.