HelloWorld级的Http服务器

4年以前  |  阅读数:209 次  |  编程语言:Golang 
package main

import "net/http"

func hello(res http.ResponseWriter, req *http.Request) {
    res.Header().Set("Content-Type", "text/plain")
    res.Write([]byte("Hello web\n"))
}

func main() {
    http.HandleFunc("/", hello)
    http.ListenAndServe(":5000", nil)
}
 相关文章:
Java版本Helloworld
使用AWT显示HelloWorld界面
PHP版HelloWorld
用C++和gtkmm 2显示HelloWorld界面
使用QT显示HelloWorld
Kotlin版本的HelloWorld
C++版HelloWorld
C语言版本的HelloWorld
Python版HelloWorld
弹出HelloWorld对话框
GTK+显示HelloWorld
Golang版HelloWorld
C#版HelloWorld
VB版本的HelloWorld
C++版的HelloWorld
JavaScript版的HelloWorld
程序员的HelloWorld
Golang官方的HelloWorld
HelloWorld级的Http服务器
Golang打印传说中的 "`hello world`"