HtServ: serve /Www/Index.HTM by default

v5
minexew 2 years ago
parent ce1d84f98f
commit e36abc087a
  1. 1
      Build/ShrineDistro.HC
  2. 2
      CHANGELOG.md
  3. 14
      Demo/Network/HtServ.HC
  4. 73
      Www/Index.HTM

@ -141,6 +141,7 @@ U0 StdDistroPrep()
CopyTree("C:/Kernel",TOS_DISTRO_DIR "/Kernel");
CopyTree("C:/Misc",TOS_DISTRO_DIR "/Misc");
// CopyTree("C:/User",TOS_DISTRO_DIR "/User");
CopyTree("C:/Www",TOS_DISTRO_DIR "/Www");
Copy("C:/HomeKeyPlugIns.HC", TOS_DISTRO_DIR "/");
Copy("C:/HomeLocalize.HC", TOS_DISTRO_DIR "/");
Copy("C:/HomeSys.HC", TOS_DISTRO_DIR "/");

@ -18,4 +18,4 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Fixed
- TCP server mode is now usable (`close` doesn't abruptly terminate the connection)
[Unreleased]: https://github.com/Shrine/compare/9317cf4f645a0072d5fa3f9abc466964d8baad4c...v5
[Unreleased]: https://github.com/minexew/Shrine/compare/9317cf4f645a0072d5fa3f9abc466964d8baad4c...v5

@ -40,6 +40,9 @@ U0 HtServProcess(CHtServSession* sess) {
if (SERVER_STRING) {
sendString(sess->sock, SERVER_STRING, 0);
}
// TODO: how about some Content-Type??
sendString(sess->sock, "\r\n", 0);
sendall(sess->sock, data, size, 0);
sess->state = STATE_TERM;
@ -108,8 +111,15 @@ U0 HtServSession(CTcpSocket* sock) {
}
sess.protocol = StrNew(protocol);
// TODO: should urldecode
sess.resource = StrNew(resource);
// FIXME: should urldecode resource
// FIXME: must check for trailing slash in general
if (!StrCmp(resource, "/")) {
sess.resource = StrNew("/Index.HTM");
}
else {
sess.resource = StrNew(resource);
}
sess.state = STATE_HEADERS;
}

@ -0,0 +1,73 @@
<!doctype html>
<html>
<head>
<title>Shrine</title>
<style>
html, body {
font-family: Roboto, sans-serif;
font-size: 24px;
background-color: #fafafa;
margin: 0;
padding: 0;
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
}
h1 {
font-size: 80px;
margin: 0em;
}
h3 {
color: #666;
margin-top: 0.5em;
}
hr {
border: 2px solid #eee;
margin: 1em 0;
}
.container {
display: flex;
justify-content: center;
}
.content {
flex-grow: 1;
max-width: 800px;
padding: 2em;
}
.octicon {
fill: #333;
}
.shrine-icon {
position: relative;
top: 6px;
}
</style>
</head>
<body>
<div class="container">
<div class="content">
<div style="text-align: center; margin-bottom: 2em; position: relative">
<h1>
<a href="https://github.com/minexew/Shrine" style="position: absolute; right: 0">
<svg class="octicon" height="80" viewBox="0 0 16 16" version="1.1" width="80" aria-hidden="true"><path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"></path></svg>
</a>
<svg class="shrine-icon" enable-background="new 0 0 512.008 512.008" height="80" viewBox="0 0 512.008 512.008" width="80" xmlns="http://www.w3.org/2000/svg"><g><path d="m352.211 466.805h-192.413v-29.401h-67.129v29.401h-33.78c-8.284 0-15 6.716-15 15s6.716 15 15 15h394.231c8.284 0 15-6.716 15-15s-6.716-15-15-15h-33.78v-29.401h-67.128v29.401z"/><path d="m352.211 204.457v202.946h67.128v-136.188h48.302c8.284 0 15-6.716 15-15v-36.789c0-8.284-6.716-15-15-15z"/><path d="m159.797 204.457-115.431-.031c-8.284 0-15 6.716-15 15v36.789c0 8.284 6.716 15 15 15h48.302v136.188h67.129z"/><path d="m333.177 159.547c0 8.222 6.689 14.91 14.911 14.91h75.376c8.222 0 14.911-6.688 14.911-14.91v-33.736c-27.2 5.13-62.609 10.301-105.197 13.337v20.399z"/><path d="m189.797 204.426v66.789h132.414v-66.789h-26.073l4.348-63.461c-14.184.571-29.014.892-44.482.892s-30.298-.322-44.482-.892l4.348 63.461z"/><path d="m163.921 174.457c8.222 0 14.911-6.688 14.911-14.91v-20.399c-42.589-3.036-77.998-8.207-105.197-13.337v33.736c0 8.222 6.689 14.91 14.911 14.91z"/><path d="m491.671 76.752v-29.251c6.014-1.714 9.449-2.852 10.125-3.079 7.85-2.646 12.069-11.155 9.423-19.006s-11.156-12.067-19.006-9.423c-.886.299-90.286 29.865-236.208 29.865-145.384 0-235.252-29.544-236.219-29.868-7.845-2.638-16.35 1.58-18.995 9.426-2.646 7.851 1.573 16.359 9.423 19.006.675.228 4.111 1.366 10.125 3.079v29.243c0 3.25 2.137 6.109 5.258 7.017 22.068 6.418 105.86 28.097 230.409 28.097 124.943 0 208.435-21.672 230.417-28.091 3.115-.911 5.248-3.768 5.248-7.015z"/></g></svg>
&nbsp;Shrine
</h1>
<h3>Connected and easy to use.</h3>
</div>
<hr>
</div>
</div>
</body>
</html>
Loading…
Cancel
Save