Commit 8ed4d6592a55d0a3666ededdfc213981ad73514b
1 parent
8bb44ece
Favicon et meilleur routage
Showing
4 changed files
with
10 additions
and
3 deletions
Show diff stats
app/routes.js
1 | 1 | var path = require('path'); |
2 | 2 | var api = require('./routes/ApiRtes'); |
3 | +var favicon = require('serve-favicon'); | |
4 | +var express = require('express'); | |
3 | 5 | |
4 | 6 | module.exports = function (app) { |
5 | 7 | |
8 | + // Statique | |
9 | + app.use(favicon(path.normalize(__dirname + '/../public/favicon.ico'))); | |
10 | + app.use(express.static(path.normalize(__dirname + '/../public'))); | |
11 | + | |
12 | + // API | |
6 | 13 | app.use('/api/', api); |
7 | 14 | |
15 | + // Défaut | |
8 | 16 | app.get('*', function (req, res) { |
9 | 17 | if (req.accepts('text/html')) { |
10 | 18 | res.sendFile('public/views/index.html', { |
... | ... | @@ -15,6 +23,7 @@ module.exports = function (app) { |
15 | 23 | } |
16 | 24 | }); |
17 | 25 | |
26 | + // Mauvaise requête | |
18 | 27 | app.all('*', function (req, res) { |
19 | 28 | res.send(405).end(); |
20 | 29 | }); | ... | ... |
package.json
No preview for this file type
server.js