Last active
October 20, 2021 11:40
-
-
Save HELLSNAKES/bc526ad784934ac7a512d0679a3c134f to your computer and use it in GitHub Desktop.
Simple api use express
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 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