Skip to content

Commit

Permalink
Test Vercel y Node.js
Browse files Browse the repository at this point in the history
  • Loading branch information
diochos committed Jun 25, 2024
1 parent 1a12f00 commit 90e9c8e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
18 changes: 15 additions & 3 deletions server.js → index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
const express = require('express');
const app = express();

const port = process.env.PORT || 3000;

const mysql = require('mysql');
const path = require('path');

Expand All @@ -20,14 +23,23 @@ app.set('views', path.join(__dirname, 'src/views'));

app.use(express.static(path.join(__dirname, 'src')));

app.get('/seguimiento', (req, res) => {
app.get("/", (req, res) => {
res.sendFile(path.join(__dirname, 'src', 'index.html'));
});

app.get("/seguimiento", (req, res) => {
db.query('SELECT valor FROM Datos LIMIT 1', (err, results) => {
if (err) throw err;
const etapa = results[0].valor;
res.render('seguimiento', { etapa });
});
});

app.listen(3000, () => {
console.log('Servidor escuchando en http://localhost:3000');
app.get("/empleadoTest", (req, res) => {
res.sendFile(path.join(__dirname, 'src', 'empleadoTest.html'));
});
/*
app.listen(port, () => {
console.log(`Servidor escuchando en http://localhost:${port}`);
});
*/
3 changes: 1 addition & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions vercel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"builds": [
{
"src": "./index.js",
"use": "@vercel/node"
}
],
"routes": [
{
"src": "/(.*)",
"dest": "/"
}
]
}

0 comments on commit 90e9c8e

Please sign in to comment.