🍈👯 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>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="wrapper">
|
<div class="wrapper">
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<span class="title">Hey, Node!</span>
|
<span class="title">Hey, Node!</span>
|
||||||
<img
|
<img
|
||||||
src="illustration.svg"
|
src="illustration.svg"
|
||||||
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>
|
||||||
<nav class="navigation">
|
</div>
|
||||||
<a href="https://glitch.com/edit/#!/remix/glitch-hello-website" class="btn--remix">
|
<nav class="navigation">
|
||||||
<img src="https://cdn.glitch.com/a9975ea6-8949-4bab-addb-8a95021dc2da%2FLogo_Color.svg?v=1602781328576" />
|
<a
|
||||||
Remix on Glitch
|
href="https://glitch.com/edit/#!/remix/glitch-hello-website"
|
||||||
</a>
|
class="btn--remix"
|
||||||
</nav>
|
>
|
||||||
|
<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
|
<!-- include the Glitch button to show what the webpage is about and
|
||||||
to make it easier for folks to view source and remix -->
|
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
|
// 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
@@ -1 +1,5 @@
|
|||||||
const flavors = { }
|
const flavors = (request, reply) => {
|
||||||
|
reply("chocolate");
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = flavors;
|
||||||
Reference in new issue
Block a user