<commit_before>var fs = require("fs");
var path = require("path");
var webpackDevMiddleware = require("webpack-dev-middleware");
var express = require("express");
var socketio = require("socket.io");
var StreamCache = require("stream-cache");
var mime = require("mime");

function Server(compiler, options) {

	// Default options
	if(!options) options = {};
	this.contentBase = options.contentBase || process.cwd();
	this.hot = options.hot;

	// Listening for events
	var invalidPlugin = function() {
		if(this.io) this.io.sockets.emit("invalid");
	}.bind(this);
	compiler.plugin("compile", invalidPlugin);
	compiler.plugin("invalid", invalidPlugin);
	compiler.plugin("done", function(stats) {
		if(!this.io) return;
		this._sendStats(this.io.sockets, stats.toJson());
		this._stats = stats;
	}.bind(this));

	// Prepare live html page
	var livePage = this.livePage = new StreamCache();
	fs.createReadStream(path.join(__dirname, "..", "client", "live.html")).pipe(livePage);

	// Prepare the live js file
	var liveJs = new StreamCache();
	fs.createReadStream(path.join(__dirname, "..", "client", "live.bundle.js")).pipe(liveJs);

	// Prepare the inlined js file
	var inlinedJs = new StreamCache();
	fs.createReadStream(path.join(__dirname, "..", "client", "index.bundle.js")).pipe(inlinedJs);

	// Init express server
	var app = this.app = new express();

	app.configure(function() {
		// serve webpack bundle
		app.use(this.middleware = webpackDevMiddleware(compiler, options));
	}.bind(this));

	app.get("/__webpack_dev_server__/live.bundle.js", function(req, res) {
		liveJs.pipe(res);
	});

	app.get("/webpack-dev-server.js", function(req, res) {
		inlinedJs.pipe(res);
	});

	app.get("/webpack-dev-server/*", function(req, res) {
		this.livePage.pipe(res);
	}.bind(this));

	// route content request
	app.get("*", this.serveContent.bind(this));
}
<commit_msg>Make live.html work on PS4 browser by adding Content-Type<commit_after>var fs = require("fs");
var path = require("path");
var webpackDevMiddleware = require("webpack-dev-middleware");
var express = require("express");
var socketio = require("socket.io");
var StreamCache = require("stream-cache");
var mime = require("mime");

function Server(compiler, options) {

	// Default options
	if(!options) options = {};
	this.contentBase = options.contentBase || process.cwd();
	this.hot = options.hot;

	// Listening for events
	var invalidPlugin = function() {
		if(this.io) this.io.sockets.emit("invalid");
	}.bind(this);
	compiler.plugin("compile", invalidPlugin);
	compiler.plugin("invalid", invalidPlugin);
	compiler.plugin("done", function(stats) {
		if(!this.io) return;
		this._sendStats(this.io.sockets, stats.toJson());
		this._stats = stats;
	}.bind(this));

	// Prepare live html page
	var livePage = this.livePage = new StreamCache();
	fs.createReadStream(path.join(__dirname, "..", "client", "live.html")).pipe(livePage);

	// Prepare the live js file
	var liveJs = new StreamCache();
	fs.createReadStream(path.join(__dirname, "..", "client", "live.bundle.js")).pipe(liveJs);

	// Prepare the inlined js file
	var inlinedJs = new StreamCache();
	fs.createReadStream(path.join(__dirname, "..", "client", "index.bundle.js")).pipe(inlinedJs);

	// Init express server
	var app = this.app = new express();

	app.configure(function() {
		// serve webpack bundle
		app.use(this.middleware = webpackDevMiddleware(compiler, options));
	}.bind(this));

	app.get("/__webpack_dev_server__/live.bundle.js", function(req, res) {
		liveJs.pipe(res);
	});

	app.get("/webpack-dev-server.js", function(req, res) {
		inlinedJs.pipe(res);
	});

	app.get("/webpack-dev-server/*", function(req, res) {
		res.setHeader("Content-Type", "text/html");
		this.livePage.pipe(res);
	}.bind(this));

	// route content request
	app.get("*", this.serveContent.bind(this));
}

{'fraction_non_alphanumeric': 0.1820324777370351, 'fraction_numerical': 0.00026191723415400735, 'mean_word_length': 4.839449541284404, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6365002', 'n_tokens_mistral': 1291, 'n_tokens_neox': 1245, 'n_words': 260}