Several features:
- Ability to serve static files, HTML and CSS are supported so far - Consequently, show a simple HTML form to enter the parameters when navigating to / (or /index.html). - Make the server multi-threaded (in a rather primitive way so far). - Use logback instead of the simple-slf4j logger.
This commit is contained in:
parent
cd29c6fe75
commit
4d0c5f5c18
7 changed files with 327 additions and 94 deletions
17
src/main/resources/logback.xml
Normal file
17
src/main/resources/logback.xml
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<shutdownHook class="ch.qos.logback.core.hook.DelayingShutdownHook"/>
|
||||
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<!-- encoders are by default assigned the type
|
||||
ch.qos.logback.classic.encoder.PatternLayoutEncoder -->
|
||||
<encoder>
|
||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="info">
|
||||
<appender-ref ref="STDOUT"/>
|
||||
</root>
|
||||
<logger name="ch.fritteli.labyrinth.server.StaticResourcesFileHandler" level="debug"/>
|
||||
</configuration>
|
32
src/main/resources/webassets/index.html
Normal file
32
src/main/resources/webassets/index.html
Normal file
|
@ -0,0 +1,32 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Labyrinth Generator</title>
|
||||
<link rel="stylesheet" href="style.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="content">
|
||||
<h1>Labyrinth Generator</h1>
|
||||
<p>Enter some values, click the "Create!" button and see what happens!</p>
|
||||
<form action="/create" method="get">
|
||||
<div class="inputs-wrapper">
|
||||
<label for="width">Width:</label><input id="width" name="width" type="number" min="1" required>
|
||||
<label for="height">Height:</label><input id="height" name="height" type="number" min="1" required>
|
||||
<label for="output">Output format:</label>
|
||||
<select id="output" name="output" required>
|
||||
<option label="HTML Document" value="html"></option>
|
||||
<option label="Plain text" value="text"></option>
|
||||
<option label="PDF Document" value="pdf"></option>
|
||||
<option label="Binary" value="binary"></option>
|
||||
</select>
|
||||
<label for="id">Seed (optional):</label><input id="id" name="id" type="number">
|
||||
</div>
|
||||
<div class="controls-wrapper">
|
||||
<button type="submit" class="primary">Create!</button>
|
||||
<button type="reset">Reset form</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
51
src/main/resources/webassets/style.css
Normal file
51
src/main/resources/webassets/style.css
Normal file
|
@ -0,0 +1,51 @@
|
|||
:root {
|
||||
--color-background: #181a1b;
|
||||
--color-foreground: #e8e6e3;
|
||||
--color-border: #5d6164;
|
||||
--color-background-highlight: #292b2c;
|
||||
--color-foreground-highlight: #f8f7f4;
|
||||
--color-border-highlight: #6e7275;
|
||||
}
|
||||
|
||||
body {
|
||||
display: flex;
|
||||
font-family: sans-serif;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
body, button, input, select {
|
||||
background-color: var(--color-background);
|
||||
color: var(--color-foreground);
|
||||
}
|
||||
|
||||
button, input, select {
|
||||
border: 1px solid var(--color-border);
|
||||
}
|
||||
|
||||
button:active, input:active, select:active,
|
||||
button:focus, input:focus, select:focus,
|
||||
button:hover, input:hover, select:hover {
|
||||
background-color: var(--color-background-highlight);
|
||||
border-color: var(--color-border-highlight);
|
||||
color: var(--color-foreground-highlight);
|
||||
}
|
||||
|
||||
button.primary {
|
||||
background-color: #ffcc00;
|
||||
border-color: #eebb00;
|
||||
color: var(--color-background);
|
||||
}
|
||||
|
||||
.content {
|
||||
width: 75%;
|
||||
}
|
||||
|
||||
.content h1 {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.inputs-wrapper {
|
||||
display: grid;
|
||||
grid-row-gap: 1em;
|
||||
grid-template-columns: 0.5fr 1fr;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue