Skip to content

Instantly share code, notes, and snippets.

@HELLSNAKES
Last active October 20, 2021 11:40
Show Gist options
  • Save HELLSNAKES/bc526ad784934ac7a512d0679a3c134f to your computer and use it in GitHub Desktop.
Save HELLSNAKES/bc526ad784934ac7a512d0679a3c134f to your computer and use it in GitHub Desktop.
Simple api use express
const express = require("express");
const app = express();
const port = process.env.PORT || 5000
app.get('/', (req,res) => {
res.send('Hello world')
})
app.get('/image', (req,res) => {
const result = {};
result.code = 200;
result.url = "https://i.imgur.com/hY5iB37.jpg";
console.log(result)
res.send(JSON.stringify(result))
})
//port
app.listen(port, "0.0.0.0", function () {
// console.log(`Server listening on port ${port}\n`);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment