Spaces:
Runtime error
Runtime error
Commit
·
bc43e0a
1
Parent(s):
53b6dea
Create app.js
Browse files
app.js
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
var request = require('request');
|
2 |
+
const http = require('http');
|
3 |
+
const ngrok = require('ngrok');
|
4 |
+
|
5 |
+
const hostname = process.env.HOST || '0.0.0.0';
|
6 |
+
const port = process.env.PORT || 7860;
|
7 |
+
|
8 |
+
const server = http.createServer((req, res) => {
|
9 |
+
res.statusCode = 200;
|
10 |
+
res.setHeader('Content-Type', 'text/plain');
|
11 |
+
res.end('Hello World');
|
12 |
+
});
|
13 |
+
|
14 |
+
server.listen(port, hostname, () => {
|
15 |
+
console.log(`Server running at http://${hostname}:${port}/`);
|
16 |
+
|
17 |
+
request('https://ipinfo.io/ip', function (error, response, body) {
|
18 |
+
if (!error && response.statusCode == 200) {
|
19 |
+
console.log(body) // Show the HTML for the Google homepage.
|
20 |
+
}
|
21 |
+
else {
|
22 |
+
console.log("Error "+response.statusCode)
|
23 |
+
}
|
24 |
+
})
|
25 |
+
|
26 |
+
(async function() {
|
27 |
+
token = process.env.AUTHTOKEN);
|
28 |
+
const url = await ngrok.connect({
|
29 |
+
addr: 7860,
|
30 |
+
authtoken: token
|
31 |
+
});
|
32 |
+
console.log(url)
|
33 |
+
})();
|
34 |
+
});
|