第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使用 Go 提供 HTML 頁面

使用 Go 提供 HTML 頁面

Go
慕妹3242003 2022-06-13 15:48:39
我正在嘗試使用 golang API 提供 HTML 頁面這是html:<!DOCTYPE HTML><html>        <body>      <section>      <div class="login-box">    <h2>Login into your account</h2>    <form method="post" action="/login">        <label for="name"></label>        <input type="text" placeholder="Username" id="name" name="name"><br>        <label for="password"></label>        <input  type="password" placeholder="Password" id="password" name="password"> <br>        <br>        <button type="submit">Login</button>    </form>               </div>      <br>    <nav class="myNav">        <ul>            <li><a href="">Don't have an account?</a>              <ul>                <li><a href="">Sing Up</a></li>                <li><a href="">Login with Google Account</a></li>              </ul>          </li>        </ul>      </nav>      </section>     </html><style>  .login-box{    font-size: large;    position:absolute;    top:50%;    left:50%;    transform: translate(-50%,-50%);  }  .login-box input{    border:none;    outline:none;    font-size:20px;    text-align: center;  }  button{  width:30%;  position:absolute;  left:70%;  background:none;  border: 2px solid white;  padding: 4px;  cursor:pointer;  font-size: 18px;  font-family: "Lucida Console", Courier, monospace;}label{  color:black;  font-family: 'Comfortaa';  font-size:30px;}body {  width:100%;  height:100vh;    background: linear-gradient(-45deg, #23D5AB, #23A6D5,#E73C7E);    background-size:300% 300%;     position:relative;    animation:change 10s ease-in-out infinite;}  @keyframes change{    0%{      background-position: 0 50%;    }    50%{      background-position: 100% 50%;    }    100%{      background-position: 0 50%;    }  }我正在使用 golang 為這個 html 提供服務(wù):router.HandleFunc("/", Utilities.LoginPage)當(dāng)我嘗試在本機或在 codepen 上呈現(xiàn) html 時,它可以工作,但是當(dāng)我使用 Go API 提供文件時,html 頁面看起來不一樣!任何幫助將不勝感激。謝謝 !
查看完整描述

1 回答

?
陪伴而非守候

TA貢獻1757條經(jīng)驗 獲得超8個贊

要托管靜態(tài)文件,您可以使用net/http 文件服務(wù)器。您可以在存儲庫中創(chuàng)建一個目錄,并使用內(nèi)置的 http.FileServer 指向您的處理程序。這是示例:


假設(shè)我們將上述文件保存index.html在 repo 下tmp


package main


import (

    "net/http"

)


func main() {

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

    http.ListenAndServe(":8080", nil)

}


查看完整回答
反對 回復(fù) 2022-06-13
  • 1 回答
  • 0 關(guān)注
  • 249 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號