Answer the question
In order to leave comments, you need to log in
What is the error in the code when routing to go?
there is a simple Go code (2 pages with a transition between them):
package main
import (
"fmt"
"net/http"
"github.com/julienschmidt/httprouter"
)
func index_page(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
http.ServeFile(w, r, "index.html")
}
func login_page(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
fmt.Fprintf(w, "тест")
}
func handleRequest() {
router := httprouter.New()
router.GET("/", index_page)
router.GET("/login", login_page)
http.Handle("/", router)
http.ListenAndServe(":8000", router)
}
func main() {
handleRequest()
}
<html>
<head>
<title>login or auth?</title>
</head>
<body>
<h2>Стартовая страничка</h2>
<a href = "login_page.html">
<input class="button" value="Войти"/>
</a>
<a href = "reg_page.html">
<input class="button" value="Регистрация"/>
</a>
</body>
</html>
Answer the question
In order to leave comments, you need to log in
Read about url, uri and it would also be desirable to study the protocol with which you are working.
so. the first stage of solving the problem turned out to be that we need to fix html, namely href:
change to
<a href = "login_page.html">
<a href = "/login">
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question