블록체인

서버 기초

Hs’s Coding vlog 2023. 12. 2. 15:38

golang언어로 웹서버를 만들어보았다.

[Golang]

package main
import (
"net/http"
)

func main(){
http.Handle("/",http.FileServer(http.Dir("Public")))
http.ListenAndServe(":8080",nil)
}

main pkg

"net/http"  요놈을 import를 해야 웹서버를 구현할수가 있다.

http.Handle("/",http.FileServer(http.Dir("Public"))) 

http.ListenAndServe(":8080",nil)

http 라이브러리를 이용해서 고랭과 html 파일을 연동하고 
포트는 :8080로 설정을했다.


[html]

<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>고랭웹서버 입니다.</title>
</head>
<body>
<h1>환영합니다.</h1>
</body>
</html>

html로 웹사이트 프론트엔드를 간단하게 구현하고
구글에다가  localhost:8080 로 입력해보니깐

이렇게 들어와진 모습을 볼수가있다.

'블록체인' 카테고리의 다른 글

RESTful  (1) 2023.12.03
서버기초[go ethereum]  (1) 2023.12.02
[Go lang] 왈루스 :=  (0) 2023.12.01
트레블룰/zchash/tronadoCash [공부 더필요!]  (0) 2023.11.29
롤업[Roll up]  (0) 2023.11.29