|
@@ -0,0 +1,48 @@
|
|
|
+package main
|
|
|
+
|
|
|
+import (
|
|
|
+ "fmt"
|
|
|
+ "net/http"
|
|
|
+)
|
|
|
+
|
|
|
+type StudentInfo struct {
|
|
|
+ FullName string `json:"full_name"`
|
|
|
+ Group string `json:"group"`
|
|
|
+}
|
|
|
+
|
|
|
+func main() {
|
|
|
+ http.HandleFunc("/ok", func(w http.ResponseWriter, r *http.Request) {
|
|
|
+ w.WriteHeader(http.StatusOK)
|
|
|
+ fmt.Fprintln(w, "OK")
|
|
|
+ })
|
|
|
+
|
|
|
+ http.HandleFunc("/info", func(w http.ResponseWriter, r *http.Request) {
|
|
|
+ student := StudentInfo{
|
|
|
+ FullName: "Смолин Алексей Михайлович",
|
|
|
+ Group: "712",
|
|
|
+ }
|
|
|
+ html := fmt.Sprintf(`
|
|
|
+ <!DOCTYPE html>
|
|
|
+ <html lang="en">
|
|
|
+ <head>
|
|
|
+ <meta charset="UTF-8">
|
|
|
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
+ <title>Info Page</title>
|
|
|
+ </head>
|
|
|
+ <body>
|
|
|
+ <h1>Информация о студенте</h1>
|
|
|
+ <p><strong>ФИО:</strong> %s</p>
|
|
|
+ <p><strong>Группа:</strong> %s</p>
|
|
|
+ </body>
|
|
|
+ </html>
|
|
|
+ `, student.FullName, student.Group)
|
|
|
+
|
|
|
+ w.Header().Set("Content-Type", "text/html")
|
|
|
+ fmt.Fprintln(w, html)
|
|
|
+ })
|
|
|
+
|
|
|
+ fmt.Println("Server is running on http://localhost:8080")
|
|
|
+ if err := http.ListenAndServe(":8080", nil); err != nil {
|
|
|
+ fmt.Println("Error starting server:", err)
|
|
|
+ }
|
|
|
+}
|