This repository has been archived by the owner on Jan 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
56 lines (46 loc) · 2.11 KB
/
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/**
* swaeg tix persister server
*/
var express = require('express');
var fs = require('fs');
//var bodyParser = require('body-parser');
var app = express();
var FILE = 'sold_tickets.txt';
// Use body parsing middleware to parse json from requests
//app.use(bodyParser.json());
// Save to file route
app.get('/save', function(request, response) {
fs.appendFile(FILE, JSON.stringify(request.query.ticket) + "\r\n", function(err) {
if (err) {
console.log(err);
return response.jsonp({'msg': "Error saving ticket code! Consult the server log."});
}
console.log("Saved data " + JSON.stringify(request.query.ticket) + " succesfully.");
});
return response.jsonp({'msg': "Ticket saved!"});
});
// Basic root route
app.get('/', function(request, response) {
response.send('Ticket server online. Blast your ticket jsonp to /save');
});
// Start the server
var server = app.listen(8080, function() {
var host = server.address().address;
var port = server.address().port;
console.log("Ticket server started.")
console.log("");
console.log("░░░░░░░░░▄░░░░░░░░░░░░░░▄");
console.log("░░░░░░░░▌▒█░░░░░░░░░░░▄▀▒▌");
console.log("░░░░░░░░▌▒▒█░░░░░░░░▄▀▒▒▒▐");
console.log("░░░░░░░▐▄▀▒▒▀▀▀▀▄▄▄▀▒▒▒▒▒▐");
console.log("░░░░░▄▄▀▒░▒▒▒▒▒▒▒▒▒█▒▒▄█▒▐");
console.log("░░░▄▀▒▒▒░░░▒▒▒░░░▒▒▒▀██▀▒▌");
console.log("░░▐▒▒▒▄▄▒▒▒▒░░░▒▒▒▒▒▒▒▀▄▒▒▌");
console.log("░░▌░░▌█▀▒▒▒▒▒▄▀█▄▒▒▒▒▒▒▒█▒▐");
console.log("░▐░░░▒▒▒▒▒▒▒▒▌██▀▒▒░░░▒▒▒▀▄▌");
console.log("░▌░▒▄██▄▒▒▒▒▒▒▒▒▒░░░░░░▒▒▒▒▌");
console.log("");
console.log("wow much swg such tix");
console.log("");
console.log("Ticket server is listening.");
});