-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
32 lines (27 loc) · 861 Bytes
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const PORT = 8000
const axios = require('axios').default
const express = require('express')
const cors = require('cors')
require('dotenv').config()
const app = express()
app.use(cors())
app.use(express.json())
app.post('/solve', (req, res) => {
const input_body = {"input": req.body.input}
const options = {
method: 'POST',
url: 'https://sudoku-solver3.p.rapidapi.com/sudokusolver/',
headers: {
'content-type': 'application/json',
'X-RapidAPI-Key': process.env.RAPID_API_KEY,
'X-RapidAPI-Host': 'sudoku-solver3.p.rapidapi.com'
},
data: input_body
}
axios.request(options).then((response) => {
res.json(response.data)
}).catch((error) => {
console.error(error);
})
})
app.listen(PORT, () => console.log(`Server listening on Port : ${PORT}`))