Spaces:
Paused
Paused
Update index.js
Browse files
index.js
CHANGED
@@ -6,7 +6,7 @@ const fs = require('fs').promises;
|
|
6 |
const rimraf = require('rimraf');
|
7 |
|
8 |
const app = express();
|
9 |
-
const PORT =
|
10 |
const UPLOAD_DIR = 'uploads';
|
11 |
|
12 |
// Middleware to handle file uploads with a 500MB limit
|
@@ -15,22 +15,18 @@ app.use(fileUpload({
|
|
15 |
abortOnLimit: true,
|
16 |
}));
|
17 |
|
18 |
-
// Serve static files (e.g., CSS, JS)
|
19 |
app.use(express.static('public'));
|
20 |
|
21 |
-
// Ensure uploads directory exists
|
22 |
(async () => {
|
23 |
if (!await fs.access(UPLOAD_DIR).then(() => true).catch(() => false)) {
|
24 |
await fs.mkdir(UPLOAD_DIR);
|
25 |
}
|
26 |
})();
|
27 |
|
28 |
-
// Serve the HTML view
|
29 |
app.get('/', (req, res) => {
|
30 |
res.sendFile(path.join(__dirname, 'views', 'index.html'));
|
31 |
});
|
32 |
|
33 |
-
// Debug APK route
|
34 |
app.post('/process/debug', async (req, res) => {
|
35 |
if (!req.files || !req.files.file || !req.files.file.name.endsWith('.apk')) {
|
36 |
return res.status(400).json({ error: 'File must be an APK' });
|
@@ -58,7 +54,6 @@ app.post('/process/debug', async (req, res) => {
|
|
58 |
}
|
59 |
});
|
60 |
|
61 |
-
// Debug APK function
|
62 |
function debugApk(inputPath, outputDir) {
|
63 |
return new Promise((resolve) => {
|
64 |
const command = `apk-mitm ${inputPath} -o ${outputDir}`;
|
@@ -74,7 +69,6 @@ function debugApk(inputPath, outputDir) {
|
|
74 |
});
|
75 |
}
|
76 |
|
77 |
-
// Cleanup function
|
78 |
async function cleanupFiles() {
|
79 |
return new Promise((resolve) => {
|
80 |
rimraf(UPLOAD_DIR, () => resolve());
|
|
|
6 |
const rimraf = require('rimraf');
|
7 |
|
8 |
const app = express();
|
9 |
+
const PORT = process.env.PORT || 8000; // Use env var or default to 8000
|
10 |
const UPLOAD_DIR = 'uploads';
|
11 |
|
12 |
// Middleware to handle file uploads with a 500MB limit
|
|
|
15 |
abortOnLimit: true,
|
16 |
}));
|
17 |
|
|
|
18 |
app.use(express.static('public'));
|
19 |
|
|
|
20 |
(async () => {
|
21 |
if (!await fs.access(UPLOAD_DIR).then(() => true).catch(() => false)) {
|
22 |
await fs.mkdir(UPLOAD_DIR);
|
23 |
}
|
24 |
})();
|
25 |
|
|
|
26 |
app.get('/', (req, res) => {
|
27 |
res.sendFile(path.join(__dirname, 'views', 'index.html'));
|
28 |
});
|
29 |
|
|
|
30 |
app.post('/process/debug', async (req, res) => {
|
31 |
if (!req.files || !req.files.file || !req.files.file.name.endsWith('.apk')) {
|
32 |
return res.status(400).json({ error: 'File must be an APK' });
|
|
|
54 |
}
|
55 |
});
|
56 |
|
|
|
57 |
function debugApk(inputPath, outputDir) {
|
58 |
return new Promise((resolve) => {
|
59 |
const command = `apk-mitm ${inputPath} -o ${outputDir}`;
|
|
|
69 |
});
|
70 |
}
|
71 |
|
|
|
72 |
async function cleanupFiles() {
|
73 |
return new Promise((resolve) => {
|
74 |
rimraf(UPLOAD_DIR, () => resolve());
|