- Init the npm repo
- Install express
- Copy server.js and app.yaml
- Copy static files to /www
- gcloud app deploy --project project-id
Last active
April 1, 2020 17:40
-
-
Save pepetox/df321d60c02adf14d2fd63982b9d5f40 to your computer and use it in GitHub Desktop.
server.js Front with GAE
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
runtime: nodejs10 | |
service: default |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "myfront", | |
"version": "1.0.0", | |
"description": "npm init", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1", | |
"start": "node server.js" | |
}, | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"express": "^4.17.1" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const path = require('path'); | |
const app = express(); | |
app.use(express.static(path.join(__dirname, 'www'))); | |
app.get('*', function(req, res) { | |
res.sendFile(path.join(__dirname, 'www', 'index.html')); | |
}); | |
const PORT = process.env.PORT || 8080; | |
app.listen(PORT, () => { | |
console.log(`Server listening on port ${PORT}...`); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment