mirror of
https://github.com/rjNemo/deno_hello
synced 2026-06-06 01:56:40 +00:00
basic frontend
This commit is contained in:
parent
b42c701f20
commit
8998c65967
3 changed files with 47 additions and 4 deletions
|
|
@ -8,10 +8,11 @@ Web app which returns the iconic Hello, World in various locales
|
|||
- [x] Select the locale by id
|
||||
- [x] Use with CLI
|
||||
- [x] Basic HTTP server
|
||||
- [ ] HTML frontend
|
||||
|
||||
## Installation
|
||||
|
||||
On macOS use HomeBrew to install `deno` then update to latest version.
|
||||
On macOS use HomeBrew to install `deno` then update to the latest version.
|
||||
|
||||
```shell
|
||||
brew install deno
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
import { Application, Router, RouterContext } from "./deps.ts";
|
||||
import { ID, sayHello, sayRandomHello } from "./src/index.ts";
|
||||
import { htmlBody } from "./view.ts";
|
||||
|
||||
const port = 8000;
|
||||
|
||||
const htmlBody = (content: string) =>
|
||||
`<!DOCTYPE html><html><body><pre>${content}</pre></body></html>`;
|
||||
|
||||
type AppOpts = { port: number };
|
||||
const get_application = ({ port }: AppOpts): Application => {
|
||||
const router = new Router();
|
||||
|
|
|
|||
44
view.ts
Normal file
44
view.ts
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
export const htmlBody = (content: string) =>
|
||||
`<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<style>
|
||||
body {
|
||||
max-width: 650px;
|
||||
margin: 40px auto;
|
||||
padding: 0 10px;
|
||||
font: 18px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
|
||||
color: #444
|
||||
}
|
||||
|
||||
h1, h2, h3 {
|
||||
line-height: 1.2
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
body {
|
||||
color: white;
|
||||
background: #444
|
||||
}
|
||||
|
||||
a:link {
|
||||
color: #5bf
|
||||
}
|
||||
|
||||
a:visited {
|
||||
color: #ccf
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport"
|
||||
content="width=device-width, initial-scale=1.0, maximum-scale=5.0, minimum-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<meta name="description" content="Simple client for Hello deno back end">
|
||||
<title>Hello client</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Hello client</h1>
|
||||
<pre id="result">${content}</pre>
|
||||
</body>
|
||||
</html>`;
|
||||
Loading…
Reference in a new issue