forked from openhubgpt/open-access-gpt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDeprecated.txt
102 lines (70 loc) · 3.36 KB
/
Deprecated.txt
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// Wait for the compiler to finish before adding middleware
// devServer.compiler.hooks.done.tap('express-middleware', () => {
// // Initialize the Express server
// const server = express();
// // Middleware to parse JSON bodies
// server.use(express.json());
// // Set the constant path to pico8.dat if it's fixed
// const PICO8_DAT_PATH = path.join(serverOrigin, 'public', 'Pic0-8', 'pico8.dat');
// // Define the /api/convertP8 route
// server.post('/convertP8', function (req, res) {
// const { P8code } = req.body;
// const inputPath = path.join(serverOrigin, 'public', 'Pic0-8', 'degademo.p8');
// const outputPath = path.join(serverOrigin, 'public', 'Pic0-8', 'degademo.js');
// // Compute the relative path from server origin to target
// const relativeP8Path = path.relative(serverOrigin, inputPath);
// const relativeJSPath = path.relative(serverOrigin, outputPath);
// console.log('Relative path:', relativeP8Path); // Outputs: public/Pic0-8/degademo.p8
// console.log('Relative path:', relativeJSPath); // Outputs: public/Pic0-8/degademo.js
// console.log(`Input path: ${inputPath}, Output path: ${outputPath}, DAT path: ${PICO8_DAT_PATH}`);
// // Write P8 code into .p8 file
// fs.writeFile(relativeP8Path, P8code, 'utf8', (writeErr) => {
// if (writeErr) {
// console.error(`Error writing file ${relativeP8Path}:`, writeErr);
// return res.status(500).send('Failed to save file');
// }
// });
// // Run the Shrinko8 command
// const pythonProcess = spawn('python', [
// path.join(serverOrigin, 'src','core','plugins','shrinko8-main','shrinko8.py'),
// inputPath,
// outputPath,
// '--pico8-dat',
// PICO8_DAT_PATH,
// ]);
// let result = '';
// pythonProcess.stdout.on('data', (data) => {
// result += data.toString();
// console.log(result);
// });
// pythonProcess.stderr.on('data', (data) => {
// console.error('Python Error:', data.toString());
// });
// pythonProcess.on('close', (code) => {
// if (code === 0) {
// // Read the output.js content here and return it in the response
// fs.readFile(outputPath, 'utf8', (readErr, jsCode) => {
// if (readErr) {
// console.error('Error reading output file:', readErr);
// return res.status(500).json({ error: 'Error reading output file' });
// }
// // Send the jsCode back in the response
// res.status(200).json({ jsCode });
// console.log('Server sent')
// });
// } else {
// res.status(500).json({ error: 'Python script failed' });
// }
// // storage.setItem('GameReady', result);
// });
// });
// // Handle all other routes with a 405 Method Not Allowed
// server.all('*', (req, res) => {
// res.status(405).json({ error: 'Method Not Allowed' });
// });
// // Start the server
// const PORT = process.env.PORT || 5000;
// server.listen(PORT, () => console.log(`Server running on port ${PORT}`));
// // Use the Express app as middleware in the dev server
// devServer.server.use(server);
// }); //hook tap bracket ending