Hi, is it possible to add a website inside a node project. Like i have a discord bot hosted on glitch, and i was wondering if i could have a website in the same project, so for example i can have poeple look at their json files really easily etc. If its possible how do i do it, and if its not could you guys add it
Hey @ramoth123 this seems like more or less the same question you’ve ended up asking at Is there any ftp access. I haven’t had a chance to put together any detailed information about editing the files like you asked over there, but it should be possible. For instance you could load the content of a json file into an HTML textarea, allow the user to modify the contents, and post it back to your app and save the contents back to the file they were working on. One challenge of doing this is how to make sure that the person’s who’s doing the editing should be able to edit the file.
As far as generically “adding a site to your bot”, in the project we’ve previously discussed you’re already doing that, more or less - when you added code like
const express = require('express'); const app = express();
and the associated
app.get() lines, that is a website in your project. You can add whatever additional functionality you desire to that site. https://expressjs.com/en/starter/basic-routing.html might be a helpful place to start with that.
Hope this helps!
Yeah, i just want to make a website in my project for now, but how do i view the website when its in a node project. Like when i click the show button the default thing comes up and not my test website i put in there a while ago…
The Show button shows you what you’ve told the Glitch project to show; in the case of the bot we were looking at earlier this is currently a static page located in
views/index.html. If you update that file then the app will show whatever you put in there.
You’ve also told Glitch to send anything in the
public folder to the browser, so you could put script files and css files in the
public directory and link to them there. So you could add
and this line in your HTML file
<link rel="stylesheet" href="/style.css">
will link to that document.
ok, so I just do my main index code in views/index.html, and add public/style.css and work from there, then the bot will show that website i made
Yep! It’s already showing that site - it just happens to be the HTML page that “comes with” some new Glitch projects.