filesharing/server.js

19 lines
589 B
JavaScript
Raw Normal View History

const { SERVER_HOST, SERVER_PORT, MONGDB_URL } = require('./config')
2022-08-25 06:34:16 +00:00
const express = require('express')
const mongoose = require('mongoose')
mongoose.connect(MONGDB_URL, (error) => {
if (error) {
console.error(error)
} else {
console.info('mongodb connected successfully')
}
})
2022-08-25 06:34:16 +00:00
const app = express()
2022-08-25 06:43:38 +00:00
app.set('view engine', 'pug')
app.get('/', async (req, res) => {
2022-08-25 06:43:38 +00:00
res.render('index', { title: 'hello, world!' })
2022-08-25 06:34:16 +00:00
})
const server = app.listen(SERVER_PORT, SERVER_HOST, () => {
console.info(`server is running at http://${SERVER_HOST}:${SERVER_PORT}`)
2022-08-25 06:34:16 +00:00
})