-
Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Description
Here is my sample:
server.js
const express = require('express');
const path = require('path');
const package = require('./package.json');
function createServer() {
const app = express();
app.set('views', path.resolve(__dirname, './views'));
app.set('view engine', 'ejs');
// app.use('/static', express.static(path.resolve(__dirname, 'public')));
app.get('/', (req, res) => {
res.render('index');
});
app.get('/version', (req, res) => {
res.send(`version: ${package.version}`);
});
const PORT = process.env.PORT || 8080;
return app.listen(PORT, () => {
console.log(`Server listening on port ${PORT}...`);
});
}
createServer();./views/index.ejs
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<link rel="stylesheet" href="static/index.css" />
<title>GAE Static File</title>
</head>
<body>
<h1 class="red">GAE Static File</h1>
</body>
</html>app.yaml:
service: static-files
runtime: nodejs8
handlers:
- url: /static
static_dir: publicworks fine.
Metadata
Metadata
Assignees
Labels
No labels
