Welcome back to the second iteration of Daily Two Cents!
Today was essentially a setup day. Since I'm using Repl.it to host my discord bot, I decided I'm going to add some sort of interface for it. So I spent today setting up all static files. I'm just going to be using plain html and css so I didn't have to install anything. You can look at the index page below, but it only has "Hello World" on it.
Now, lets get into the explanation of how I set this up.
const express = require('express');
const app = express();
const port = 3000;
This is just getting express and setting up the app. I save the port to a variable so I can use it one I start listening to it.
app.use(express.static('public'));
This line just allows me to access static assets, including css files, photos, etc.
app.get('/', (req, res) => {
res.sendFile(path.join(__dirname + '/public/index.html'));
});
This code block goes to the index file. It sends that specific file when you go to the '/' path.
app.listen(port, () =>
console.log(`
Example app listening at http://localhost:${port}
`)
);
And finally, I have this here so I know that the app is listening.
- You can check out the bot code here
As I mentioned before, I'm not sure what I'm going to put on this page yet, but I'll think of what I can do with this page over the weekend.
This was all I worked on today, so I'll sign off here. Thanks for reading and I'll see you guys tomorrow!