🍈👯 Checkpoint

./server.js:617503/1976
./src/api/flavors.js:617503/88
./public/index.html:617503/2808
This commit is contained in:
Glitch (glitch-hello-node) committed 2021-03-17 18:10:21 +00:00
1 parent 1ada30cbbb
commit de2e80ac99
3 files changed
+21 -19

No files matched your search

+8 -7
View File
@@ -22,16 +22,17 @@
class="illustration" class="illustration"
alt="Javascript logo" alt="Javascript logo"
/> />
<div> <div></div>
<form>
<input type="input" name="username" placeholder="Glitch Username" />
</form>
</div>
</div> </div>
</div> </div>
<nav class="navigation"> <nav class="navigation">
<a href="https://glitch.com/edit/#!/remix/glitch-hello-website" class="btn--remix"> <a
<img src="https://cdn.glitch.com/a9975ea6-8949-4bab-addb-8a95021dc2da%2FLogo_Color.svg?v=1602781328576" /> href="https://glitch.com/edit/#!/remix/glitch-hello-website"
class="btn--remix"
>
<img
src="https://cdn.glitch.com/a9975ea6-8949-4bab-addb-8a95021dc2da%2FLogo_Color.svg?v=1602781328576"
/>
Remix on Glitch Remix on Glitch
</a> </a>
</nav> </nav>
+8 -11
View File
@@ -1,4 +1,5 @@
const path = require('path') const path = require("path");
const flavors = require("./src/api/flavors");
// Require the framework and instantiate it // Require the framework and instantiate it
const fastify = require("fastify")({ const fastify = require("fastify")({
@@ -6,22 +7,18 @@ const fastify = require("fastify")({
}); });
// Setup our static files // Setup our static files
fastify.register(require('fastify-static'), { fastify.register(require("fastify-static"), {
root: path.join(__dirname, 'public'), root: path.join(__dirname, "public"),
prefix: '/', // optional: default '/' prefix: "/" // optional: default '/'
}) });
// Our home page route, this pulls from public/index.html // Our home page route, this pulls from public/index.html
// but you don't have to send a html, or even have a webpage! // but you don't have to send a html, or even have a webpage!
fastify.get("/", function(request, reply) { fastify.get("/", function(request, reply) {
return reply.sendFile('index.html') return reply.sendFile("index.html");
}); });
fastify.get("/api/flavors", flavors);
// Our API route, fastify automatically turns it to JSON
fastify.get("/api/flavors", function(request, reply) {
reply.send({ hello: 'world' })
});
// Run the server and report out to the logs // Run the server and report out to the logs
fastify.listen(process.env.PORT, function(err, address) { fastify.listen(process.env.PORT, function(err, address) {
+5 -1
View File
@@ -1 +1,5 @@
const flavors = { } const flavors = (request, reply) => {
reply("chocolate");
}
module.exports = flavors;