mirror of
https://github.com/CrowCpp/Crow.git
synced 2024-06-07 21:10:44 +00:00
Merge pull request #226 from jcoffin01/fix_url
Modified websocket example to automatically retrieve server's hostname.
This commit is contained in:
commit
51d51bac9b
@ -33,8 +33,13 @@ int main()
|
||||
|
||||
CROW_ROUTE(app, "/")
|
||||
([]{
|
||||
char name[256];
|
||||
gethostname(name, 256);
|
||||
crow::mustache::context x;
|
||||
x["servername"] = name;
|
||||
|
||||
auto page = crow::mustache::load("ws.html");
|
||||
return page.render();
|
||||
return page.render(x);
|
||||
});
|
||||
|
||||
app.port(40080)
|
||||
|
@ -11,7 +11,7 @@
|
||||
<textarea id="log" cols=100 rows=50>
|
||||
</textarea>
|
||||
<script>
|
||||
var sock = new WebSocket("ws://i.ipkn.me:40080/ws");
|
||||
var sock = new WebSocket("ws://{{servername}}:40080/ws");
|
||||
sock.onopen = ()=>{
|
||||
console.log('open')
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user