Commit fd4a4f8a authored by Rodrigo Diez's avatar Rodrigo Diez

Inicio

parents
Pipeline #42 failed with stages
node_modules/
const express = require('express');
const path = require('path');
const exphbs = require('express-handlebars');
require('./src/database'); //conexion a base de datos
const app = express(); //Se declara el servidor
app.set('port', 11111); //Se establece el puerto del servidor
app.set('views', path.join(__dirname, 'src/vistas')); //Directorio para las vistas
app.engine('.hbs', exphbs({ //Configuracion del motor de vistas
defaultLayout: 'principal',
layoutsDir: path.join(app.get('views'), 'plantillas'),
partialsDir: path.join(app.get('views'), 'parciales'),
extname: '.hbs',
}));
app.set('view engine', '.hbs');
//Rutas
app.use(require('./src/rutas/inicio'));
//Campos estaticos
app.use(express.static(path.join(__dirname, './src/public'))); //Directorio para los recursos estaticos de la web
//Servidor en escucha
app.listen(app.get('port'), () =>{
console.log('Servidor ejecutandose en el puerto:', app.get('port'));
});
This diff is collapsed.
{
"name": "plantilla-men",
"version": "1.0.0",
"description": "Plantilla de inicio para aplicaciones basicas NODE",
"main": "index.js",
"scripts": {
"test": "node index.js"
},
"repository": {
"type": "git",
"url": "http://git.diezrofer.es/diezrofer/plantilla-men.git"
},
"author": "DiezRoFer",
"license": "MIT",
"dependencies": {
"express": "^4.17.1",
"express-handlebars": "^3.1.0",
"mongoose": "^5.8.2",
"mongose": "0.0.2-security",
"path": "^0.12.7"
}
}
const mongoose = require('mongoose');
mongoose.connect('mongodb://192.168.1.2/test', {
useCreateIndex: true,
useNewUrlParser: true,
useFindAndModify: false,
useUnifiedTopology: true
})
.then(db => console.log('Conectado a la Base de datos'))
.catch(err => console.error(err));
/*
const mongoose = require('mongoose');
const { Schema } = mongoose;
const EsquemaEjemplo = new Schema({
nombre: { type: String},
direccion: { type: String},
fecha: { type: Date, default: Date.now},
cliente: { type: String, required: true}
});
module.exports = mongoose.model('Ejemplo', EsquemaEjemplo);
*/
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
const router = require('express').Router();
//const Consulta = require('../modelos/Ejemplo');
router.get('/', async(req, res) =>{
res.render('inicio/inicio');
});
router.get('/consultas', async(req, res) =>{
res.render('inicio/consultas');
});
module.exports = router;
\ No newline at end of file
<div class="row">
<div class="col-xs-10 col-xs-offset-1 col-sm-8 col-sm-offset-2 col-md-4 col-md-offset-4 align-content-center text-center">
<div class="login-panel panel panel-default">
<div class="panel-heading">Texto de ejemplo</div>
<div class="panel-body ">
<form role="form" action="/" method="get">
<fieldset>
<div class="form-group">
<input class="form-control" placeholder="URL" name="direccion" type="text" autofocus="">
</div>
<button class="btn btn-primary align-content-center" type="submit">Boton 1</button>
<a href="#" class="btn btn-primary align-content-center" >Boton 2</a>
</form>
</div>
</div>
</div><!-- /.col-->
</div><!-- /.row -->
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>DiezRoFer</title>
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/styles.css" rel="stylesheet">
<link href="css/font-awesome.min.css" rel="stylesheet">
</head>
<body>
{{{body}}}
<script src="js/jquery-1.11.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</body>
</html>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment