🍈👯 Checkpoint
./server.js:617503/1976 ./src/api/flavors.js:617503/88 ./public/index.html:617503/2808
This commit is contained in:
1 parent
1ada30cbbb
commit
de2e80ac99
3 files changed
+33
-31
No files matched your search
+20
-19
@@ -15,26 +15,27 @@
|
||||
</head>
|
||||
<body>
|
||||
<div class="wrapper">
|
||||
<div class="content">
|
||||
<span class="title">Hey, Node!</span>
|
||||
<img
|
||||
src="illustration.svg"
|
||||
class="illustration"
|
||||
alt="Javascript logo"
|
||||
/>
|
||||
<div>
|
||||
<form>
|
||||
<input type="input" name="username" placeholder="Glitch Username" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="content">
|
||||
<span class="title">Hey, Node!</span>
|
||||
<img
|
||||
src="illustration.svg"
|
||||
class="illustration"
|
||||
alt="Javascript logo"
|
||||
/>
|
||||
<div></div>
|
||||
</div>
|
||||
<nav class="navigation">
|
||||
<a 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
|
||||
</a>
|
||||
</nav>
|
||||
</div>
|
||||
<nav class="navigation">
|
||||
<a
|
||||
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
|
||||
</a>
|
||||
</nav>
|
||||
|
||||
<!-- include the Glitch button to show what the webpage is about and
|
||||
to make it easier for folks to view source and remix -->
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
const path = require('path')
|
||||
const path = require("path");
|
||||
const flavors = require("./src/api/flavors");
|
||||
|
||||
// Require the framework and instantiate it
|
||||
const fastify = require("fastify")({
|
||||
@@ -6,22 +7,18 @@ const fastify = require("fastify")({
|
||||
});
|
||||
|
||||
// Setup our static files
|
||||
fastify.register(require('fastify-static'), {
|
||||
root: path.join(__dirname, 'public'),
|
||||
prefix: '/', // optional: default '/'
|
||||
})
|
||||
fastify.register(require("fastify-static"), {
|
||||
root: path.join(__dirname, "public"),
|
||||
prefix: "/" // optional: default '/'
|
||||
});
|
||||
|
||||
// Our home page route, this pulls from public/index.html
|
||||
// but you don't have to send a html, or even have a webpage!
|
||||
fastify.get("/", function(request, reply) {
|
||||
return reply.sendFile('index.html')
|
||||
return reply.sendFile("index.html");
|
||||
});
|
||||
|
||||
|
||||
// Our API route, fastify automatically turns it to JSON
|
||||
fastify.get("/api/flavors", function(request, reply) {
|
||||
reply.send({ hello: 'world' })
|
||||
});
|
||||
fastify.get("/api/flavors", flavors);
|
||||
|
||||
// Run the server and report out to the logs
|
||||
fastify.listen(process.env.PORT, function(err, address) {
|
||||
|
||||
+5
-1
@@ -1 +1,5 @@
|
||||
const flavors = { }
|
||||
const flavors = (request, reply) => {
|
||||
reply("chocolate");
|
||||
}
|
||||
|
||||
module.exports = flavors;
|
||||
Reference in new issue
Block a user