Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[<PropertyGroup>const express = require('express'); const dotenv = require("dotenv"); var path = require("path"); dotenv.config({ path: ".env" }); const app = express(); app.use(express.json()); app.use(express.static(path.join(__dirname, 'public'))); const mysql = require('mysql2'); const connection = mysql.createConnection({ host: process.env.HOST, user: process.env.DB_USER, password: process.env.PASS, database: process.env.DB }); connection.connect((err) => { if (err) { console.log("Error connecting to the database", err); }else { console.log("Connected to the database!"); } }) app.get('/data', (req, res) => { const sql = 'SELECT Min, Max, HeadHousehold, Single, MarriedSeperately, MarriedJointly FROM Tax'; connection.query(sql, (err, data) => { if (err) return res.json(err); return res.json(data); }) }) app.get('/', function (req, res) { res.sendFile(path.join(__dirname, 'public', 'index.html')); }); #17

Open
Zipitn opened this issue May 23, 2024 · 0 comments

Comments

@Zipitn
Copy link

Zipitn commented May 23, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant