-
Notifications
You must be signed in to change notification settings - Fork 1
/
App.js
60 lines (52 loc) · 2.3 KB
/
App.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//Import express.js module and create its variable.
const express=require('express');
const app=express();
var bodyParser = require('body-parser')
app.use( bodyParser.json() ); // to support JSON-encoded bodies
app.use(bodyParser.urlencoded({ // to support URL-encoded bodies
extended: true
}));
app.use(express.json()); // to support JSON-encoded bodies
app.use(express.urlencoded()); // to support URL-encoded bodies
//Import PythonShell module.
const {PythonShell} =require('python-shell');
app.post("/Promptpost", (req, res, next)=>{
console.log("POST REQUEST");
// console.log(req.body);
promptforsys = req.body.prompt;
console.log(promptforsys);
numberforsys = req.body.number;
// let options = {
// mode: 'text',
// pythonOptions: ['-u'], // get print results in real-time
// // scriptPath: '/Users/adityav/Downloads/GitHub/incubator-text-to-nft/mint.py', //If you are having python_test.py script in same folder, then it's optional.
// args: [keyforsys, addressforsys] //An argument which can be accessed in the script using sys.argv[1]
// };
// PythonShell.run('mint.py', options, function (err, result){
// if (err) throw err;
// });
// We will have to respond with the URL of the generated image.
res.redirect("/MVP")
});
app.post("/Walletpost", (req, res, next)=>{
console.log("POST REQUEST");
// console.log(req.body);
addressforsys = req.body.address;
keyforsys = req.body.key;
console.log(addressforsys);
console.log(keyforsys);
let options = {
mode: 'text',
pythonOptions: ['-u'], // get print results in real-time
// scriptPath: '/Users/adityav/Downloads/GitHub/incubator-text-to-nft/mint.py', //If you are having python_test.py script in same folder, then it's optional.
args: [addressforsys, promptforsys, keyforsys, numberforsys] //An argument which can be accessed in the script using sys.argv[1]
};
PythonShell.run('NFTMint.py', options, function (err, result){
if (err) throw err;
});
// We will have to respond with the URL of the generated image.
res.redirect("/MVP")
});
//Creates the server on default port 8000 and can be accessed through localhost:8000
const port= process.env.PORT || 8000;
app.listen(port, ()=>console.log(`Server connected to ${port}`));