<commit_before>var config = require('./config')
  , Relax = require('relax')
  , vacuum = require('vacuum')
  , ramstatic = require('ram-static')
  , http = require('http')
  , hat = require('hat')
  , querystring = require('querystring')
  , user = require('./user')
  , parseURL = require('url').parse
  , post = require('./post')

var HAT_TOKEN = /^[a-f0-9]{32}$/
if (!HAT_TOKEN.test(hat())) throw new Error('weird')

if (!config.hmacSecret) config.hmacSecret = hat(512)

var ramstaticServer = ramstatic(__dirname+'/static')
exports.ramstatic = ramstaticServer
var renderTemplate = vacuum.loadSync(__dirname+'/templates')
vacuum.copyProps(renderTemplate, require('./functions'))
var db = exports.db = new Relax(config.database)

var httpServer = http.createServer(requestHandler)
function requestHandler(req, res) {
  var urlparts = parseURL(req.url).pathname.split('/').filter(function(str) {
    return str.length > 0
  })
  
  // static files
  if (urlparts[0] === 'static' && (req.method === 'GET' || req.method === 'HEAD')) {
    return ramstaticServer.handle(urlparts.slice(1).join('/'), res)
  }
  if (urlparts[0] === 'favicon.ico' && (req.method === 'GET' || req.method === 'HEAD')) {
    return ramstaticServer.handle('favicon.ico/a', res)
  }
  
  // collect POST data and verify formtoken
  if (req.method === 'POST' && !req.postData) return bufferPost(req, res)
  
  if (!req.username) {
    var authedAs = getCookie(req, 'Authed-As')
    if (authedAs) {
      req.username = user.checkSignedLogin(authedAs)
    }
  }
  
  if (config.debug) console.log((req.username ? req.username : '<anonymous>')+': '+req.method+' '+req.url)
  
  // intercept POST with loginUser or registerUser
  if (maybeInterceptLoginOrRegister(req, res)) return<commit_msg>"/" -> "/superforum"<commit_after>var config = require('./config')
  , Relax = require('relax')
  , vacuum = require('vacuum')
  , ramstatic = require('ram-static')
  , http = require('http')
  , hat = require('hat')
  , querystring = require('querystring')
  , user = require('./user')
  , parseURL = require('url').parse
  , post = require('./post')

var HAT_TOKEN = /^[a-f0-9]{32}$/
if (!HAT_TOKEN.test(hat())) throw new Error('weird')

if (!config.hmacSecret) config.hmacSecret = hat(512)

var ramstaticServer = ramstatic(__dirname+'/static')
exports.ramstatic = ramstaticServer
var renderTemplate = vacuum.loadSync(__dirname+'/templates')
vacuum.copyProps(renderTemplate, require('./functions'))
var db = exports.db = new Relax(config.database)

var httpServer = http.createServer(requestHandler)
function requestHandler(req, res) {
  var urlparts = parseURL(req.url).pathname.split('/').filter(function(str) {
    return str.length > 0
  })
  
  if (urlparts.length === 0) urlparts = ['superforum']
  
  // static files
  if (urlparts[0] === 'static' && (req.method === 'GET' || req.method === 'HEAD')) {
    return ramstaticServer.handle(urlparts.slice(1).join('/'), res)
  }
  if (urlparts[0] === 'favicon.ico' && (req.method === 'GET' || req.method === 'HEAD')) {
    return ramstaticServer.handle('favicon.ico/a', res)
  }
  
  // collect POST data and verify formtoken
  if (req.method === 'POST' && !req.postData) return bufferPost(req, res)
  
  if (!req.username) {
    var authedAs = getCookie(req, 'Authed-As')
    if (authedAs) {
      req.username = user.checkSignedLogin(authedAs)
    }
  }
  
  if (config.debug) console.log((req.username ? req.username : '<anonymous>')+': '+req.method+' '+req.url)
  
  // intercept POST with loginUser or registerUser
  if (maybeInterceptLoginOrRegister(req, res)) return
{'fraction_non_alphanumeric': 0.18194483142936752, 'fraction_numerical': 0.006408470325996099, 'mean_word_length': 4.195369030390738, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 8, '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': '840297', 'n_tokens_mistral': 1219, 'n_tokens_neox': 1187, 'n_words': 249}