I have a problem with inject script in html file. I inserted into body my primary script and it does not work. I don't have idea how to fix that, and I don't have idea how to find a respone on google... Just help me please. Thanks :)
Files structure:
_node_modules
_src:
____app.js
____style.css
add.html
index.html
package-lock.json
package.json
server.js
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Doc</title>
</head>
<body>
<script src="./src/app.js"></script>
</body>
</html>
app.js
alert("test")
server.js
const PORT = "3030";
const express = require('express')
const mysql = require('mysql')
const app = express()
app.use(express.static('src'))
const con = mysql.createConnection({
host: "localhost",
user: "root",
password: "",
database: "expenseapp"
})
con.connect(err=>{
if(err)
throw err;
console.log('connected!');
})
app.get('/',(req,resp)=>{
let array = []
let queryName = "SELECT * from `expenses`";
con.query(queryName, (err,res)=>{
if(err){
console.log(err);
res.sendStatus(500);
return;
}
res.forEach(element => {
array.push(element)
});
resp.json(array)
})
})
app.listen(PORT, ()=>console.log(`Server's running on PORT ${PORT}`))