-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/sh | ||
|
||
lein run -m clj.core |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"github.com/julienschmidt/httprouter" | ||
"html/template" | ||
"log" | ||
"net/http" | ||
) | ||
|
||
var NAMES = []string{"yoavlt", "entotsu", "morishitter"} | ||
|
||
func RenderHtml(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { | ||
tmpl := template.Must(template.ParseFiles("views/index.html")) | ||
|
||
err := tmpl.ExecuteTemplate(w, "base", NAMES) | ||
if err != nil { | ||
log.Fatal("ListenAndServe: ", err) | ||
} | ||
} | ||
|
||
func RenderName(w http.ResponseWriter, r *http.Request, ps httprouter.Params) { | ||
fmt.Fprintf(w, "Hello, %s!", ps.ByName("name")) | ||
} | ||
|
||
func main() { | ||
router := httprouter.New() | ||
router.GET("/body/:name", RenderName) | ||
router.GET("/render/html", RenderHtml) | ||
|
||
err := http.ListenAndServe(":4001", router) | ||
if err != nil { | ||
log.Fatal("ListenAndServe: ", err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{{define "base"}} | ||
<!DOCTYPE html> | ||
<html lang="ja"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<meta name="description" content=""> | ||
<meta name="author" content=""> | ||
|
||
<title>マンメンミ</title> | ||
</head> | ||
|
||
<body> | ||
<div class="container"> | ||
<div class="header"> | ||
<span class="logo"></span> | ||
</div> | ||
|
||
<ul> | ||
{{range .}} | ||
<li> | ||
<p>{{.}}</p> | ||
</li> | ||
{{end}} | ||
</ul> | ||
|
||
<div class="footer"> | ||
</div> | ||
|
||
</div> <!-- /container --> | ||
</body> | ||
</html> | ||
{{end}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
|
||
MIX_ENV=prod mix do deps.get, compile | ||
MIX_ENV=prod elixir -pa _build/prod/consolidated -S mix server |