-
Notifications
You must be signed in to change notification settings - Fork 2
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
23 changed files
with
1,078 additions
and
17 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 |
---|---|---|
@@ -1,23 +1,23 @@ | ||
package server | ||
import "net/http" | ||
import "net" | ||
import "html/template" | ||
import "log" | ||
import "strconv" | ||
|
||
func InitAdminPort(port int) error { | ||
mux := http.NewServeMux() | ||
f := func(w http.ResponseWriter, r *http.Request) { | ||
} | ||
mux.HandleFunc("/admin", f) | ||
addr := "0.0.0.0:" + strconv.Itoa(port) | ||
server := &http.Server{Addr: addr, Handler: mux} | ||
listener, err := net.Listen("tcp", addr) | ||
if err != nil { | ||
return err | ||
} | ||
log.Println("begin serve admin port:", addr) | ||
go server.Serve(listener) | ||
return nil | ||
func InitAdminPort(addr, websock string) error { | ||
http.Handle("/css/", http.FileServer(http.Dir("website"))) | ||
http.Handle("/fonts/", http.FileServer(http.Dir("website"))) | ||
http.Handle("/js/", http.FileServer(http.Dir("website"))) | ||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { | ||
t, er := template.ParseFiles("website/index.html") | ||
if er == nil { | ||
t.Execute(w, websock) | ||
} else { | ||
log.Println("err:", er.Error()) | ||
} | ||
}) | ||
log.Println("begin serve http:", addr) | ||
er := http.ListenAndServe(addr, nil) | ||
return er | ||
} | ||
|
||
|
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 |
---|---|---|
@@ -1,11 +1,17 @@ | ||
package server | ||
|
||
import "flag" | ||
import "log" | ||
|
||
var service = flag.String("service", "", "for remote client connect") | ||
var webservice = flag.String("web", ":8080", "http server port") | ||
var websocket = flag.String("websocket", ":8081", "http web-socket port") | ||
var websocket = flag.String("websocket", "10.240.160.17:8081", "http web-socket port") | ||
func Init() { | ||
flag.Parse() | ||
er:=InitAdminPort(*webservice, *websocket) | ||
if er !=nil { | ||
log.Println("web server fail", er.Error()) | ||
return | ||
} | ||
Listen(*service) | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
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,82 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta name="description" content=""> | ||
<title>gds</title> | ||
<link href="css/sui.min.css" rel="stylesheet"> | ||
<script type="text/javascript" src="js/jquery-1.10.2.min.js"></script> | ||
<script type="text/javascript" src="js/sui.min.js"></script> | ||
</head> | ||
<body> | ||
<div class="sui-layout"> | ||
<div class="sidebar"> | ||
<ul class="sui-nav nav-tabs nav-large tab-vertical"> | ||
<li><a>语文</a></li> | ||
<li class="active"><a href="#index" data-toggle="tab">数学</a></li> | ||
<li><a href="#profile" data-toggle="tab">英语</a></li> | ||
</ul> | ||
</div> | ||
<div class="content"> | ||
<div class="tab-content tab-wraped"> | ||
<div id="index" class="tab-pane active"> | ||
<p>qui irure terry richardson ex squid. Aliquip placeat salvia cillum iphone. Seitan aliquip quis cardigan american apparel, butcher voluptate nisi qui.</p> | ||
</div> | ||
<div id="profile" class="tab-pane"> | ||
<p>Art party scenester stumptown, tumblr butcher vero sint qui sapiente accusamus tattooed echo park</p> | ||
</div> | ||
<div id="about" class="tab-pane"> | ||
<p>Scenester cred you probably haven't heard of them, vinyl craft beer blog stumptown. Pitchfork sustainable tofu synth chambray yr.</p> | ||
</div> | ||
<div id="help" class="tab-pane"> | ||
<p>help!!!help!!!help!!!help!!!help!!!help!!!help!!!help!!!help!!!help!!!help!!!</p> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<script> | ||
function Decode(content) { | ||
var vars = content.split(":"); | ||
var head, msg; | ||
if (vars.length > 0) { | ||
head = vars[0]; | ||
} | ||
if (vars.length > 1) { | ||
msg = ""; | ||
for(var i=1;i<vars.length;i++) { | ||
if(i==1) { | ||
msg=vars[i]; | ||
} | ||
else { | ||
msg=msg+":"+vars[i]; | ||
} | ||
} | ||
} | ||
return [head, msg]; | ||
} | ||
|
||
function OnRecv(data) { | ||
var arr= Decode(data) | ||
var head = arr[0]; | ||
var msg= arr[1]; | ||
switch(head){ | ||
case "needinit": | ||
} | ||
} | ||
if (window["WebSocket"]) { | ||
conn = new WebSocket("ws://{{.}}/ws"); | ||
conn.onclose = function() { | ||
} | ||
conn.onerror = function(ev) { | ||
$.alert("connect error"); | ||
} | ||
conn.onmessage = function(evt) { | ||
OnRecv(evt.data); | ||
} | ||
} else { | ||
$.alert("<div><b>Your browser does not support WebSockets.</b></div>"); | ||
} | ||
</script> | ||
</body> | ||
</html> |
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.