Prompt used: Please write a simple chat app using Node.js and Socket.io
Express.js for server, Socket.io for realtime communication, and plain HTML, CSS, JavaScript for frontend.
# Clone the git repo and cd into it
npm install # installs the dependencies
node server.js # starts the server
ChatGPT puts everything together in a single file. We need to separate the code into different files. We will use the following structure:
- Split
index.html
into 3 files,index.html
,style.css
, andscript.js
. - Crate a
public
folder and put all these files there. - In
server.js
, useexpress.static
module for/public
folder. (Line number 10)
Replace the following words with emojis:
{
"react": "โ๏ธ",
"woah": "๐ฎ",
"hey": "๐",
"lol": "๐",
"like": "โค๏ธ",
"congratulations": "๐"
}