Skip to content

Instantly share code, notes, and snippets.

@internetsadboy
Created July 26, 2020 01:31
Show Gist options
  • Save internetsadboy/b082985031411e970fca7fe0f3b1d9cb to your computer and use it in GitHub Desktop.
Save internetsadboy/b082985031411e970fca7fe0f3b1d9cb to your computer and use it in GitHub Desktop.
"index.js" for express (upwork proposal question) - JARED LAMONT
const express = require('express');
const path = require('path');
// initialize app
const app = express();
const port = 3000;
// assuming ~/public/index.html
app.get('/html', (req, res) => {
res.sendFile(path.join(__dirname, 'public', 'index.html'));
})
// json example
app.get('/json', (req, res) => res.json({ please: 'hire me' }));
// geojson example
// GeoJSON uses the JSON standard
app.get('/geojson', (req, res) => {
res.json({
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [125.6, 10.1]
},
"properties": {
"name": "Dinagat Islands"
}})
}
);
app.listen(port, () => console.log(`express api test app => http://localhost:${port}`))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment