1 Star 1 Fork 0

湖底观景/GolangTraining

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
hello.go 832 Bytes
一键复制 编辑 原始数据 按行查看 历史
GoesToEleven 提交于 2016-04-21 08:45 +08:00 . changes dir structure
package main
import (
"github.com/rwcarlsen/goexif/exif"
"html/template"
"log"
"net/http"
"os"
)
const GoogleAPIKey = "AIzaSyDpMNCWNz2UENVGQOS6zMFvtLsXn0zMBf4"
var tpls *template.Template
func init() {
var err error
tpls, err = template.ParseFiles("assets/templates/index.gohtml")
if err != nil {
log.Fatalln(err)
}
http.HandleFunc("/", handleIndex)
}
func handleIndex(res http.ResponseWriter, req *http.Request) {
src, _ := os.Open("assets/img/IMG_20150714_191905.jpg")
defer src.Close()
x, _ := exif.Decode(src)
lat, lon, _ := x.LatLong()
var model struct {
Latitude, Longitude float64
Key string
}
model.Latitude = lat
model.Longitude = lon
model.Key = GoogleAPIKey
err := tpls.ExecuteTemplate(res, "index.gohtml", model)
if err != nil {
http.Error(res, err.Error(), 500)
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhangjianGood/GolangTraining.git
git@gitee.com:zhangjianGood/GolangTraining.git
zhangjianGood
GolangTraining
GolangTraining
afa19f5c43f3

搜索帮助