260703_000219
This commit is contained in:
parent
ba85ab166d
commit
25529fbe5e
17
moira_db.go
17
moira_db.go
@ -36,7 +36,7 @@ type Film struct{
|
|||||||
|
|
||||||
Year int
|
Year int
|
||||||
}
|
}
|
||||||
//var db_film []Film
|
var db_film []Film
|
||||||
|
|
||||||
|
|
||||||
func findURL_in_msg(in_msg string) (_ string,err error){
|
func findURL_in_msg(in_msg string) (_ string,err error){
|
||||||
@ -207,7 +207,15 @@ func hdlr_root(template_renders map[string]string) http.HandlerFunc{
|
|||||||
if fileName, ok := template_renders[req.URL.Path]; ok{
|
if fileName, ok := template_renders[req.URL.Path]; ok{
|
||||||
fmt.Println("[srv] template", req.URL.Path, fileName)
|
fmt.Println("[srv] template", req.URL.Path, fileName)
|
||||||
|
|
||||||
err := templates.ExecuteTemplate(resp, fileName, nil)
|
url_query := req.URL.Query()
|
||||||
|
url_query_id := url_query.Get("id")
|
||||||
|
var context any
|
||||||
|
if(url_query_id != ""){
|
||||||
|
context = db_film[int(url_query_id)]
|
||||||
|
}else{
|
||||||
|
context = nil
|
||||||
|
}
|
||||||
|
err := templates.ExecuteTemplate(resp, fileName, context)
|
||||||
|
|
||||||
if(err != nil){
|
if(err != nil){
|
||||||
http.Error(resp, err.Error(), http.StatusInternalServerError)
|
http.Error(resp, err.Error(), http.StatusInternalServerError)
|
||||||
@ -241,10 +249,13 @@ func hdlr_film_parseMsg(resp http.ResponseWriter, req *http.Request){
|
|||||||
t_url_noRed, _ := resolve_redirs(t_url)
|
t_url_noRed, _ := resolve_redirs(t_url)
|
||||||
fmt.Println(t_url_noRed)
|
fmt.Println(t_url_noRed)
|
||||||
t_film, _ := fetch_filmInfo(t_url_noRed)
|
t_film, _ := fetch_filmInfo(t_url_noRed)
|
||||||
|
|
||||||
|
db_film = append(db_film, t_film)
|
||||||
|
|
||||||
t_json, _ := json.MarshalIndent(t_film, "", " ")
|
t_json, _ := json.MarshalIndent(t_film, "", " ")
|
||||||
fmt.Printf("%+v\n", string(t_json))
|
fmt.Printf("%+v\n", string(t_json))
|
||||||
|
|
||||||
http.Redirect(resp, req, "/film/view/"+t_film.Title_orig, http.StatusFound)
|
http.Redirect(resp, req, "/film/view/"+string(len(db_film)-1), http.StatusFound)
|
||||||
}
|
}
|
||||||
|
|
||||||
func main(){
|
func main(){
|
||||||
|
|||||||
@ -13,13 +13,11 @@
|
|||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<input type="text" id="inEl">
|
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<h1 id="filmInfo_title"></h1>
|
<h1 id="filmInfo_title">{{.Title_orig}}</h1>
|
||||||
<h3 id="filmInfo_year"></h3></br>
|
<h3 id="filmInfo_year">{{.Year}}</h3></br>
|
||||||
<p id="filmInfo_desc"></p></br>
|
<p id="filmInfo_desc">{{.Desc}}</p></br>
|
||||||
<img id="filmInfo_img" width="300" />
|
<img id="filmInfo_img" width="300" src="{{.Img}}"/>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user