<commit_before>routes = {}
routes['^/(.*).(jpg|gif|png|css|js|ico|swf|flv|mp3|mp4|woff|eot|ttf|otf|svg)'] = function()
    header('Cache-Control: max-age=864000')
    sendfile(headers.uri)
end

routes['^/user/:user_id(.*)'] = function(r)
    print('User ID: ', r.user_id)
end

routes['^/(.*)'] = function(r)
    dofile('/index.lua')
end

--[[
others you want :)
]]

if not router(headers.uri, routes) then
    header('HTTP/1.1 404 Not Found')
    echo('File Not Found!')
end<commit_msg>add route.lua example<commit_after>routes = {}
routes['^/(.*).(jpg|gif|png|css|js|ico|swf|flv|mp3|mp4|woff|eot|ttf|otf|svg)'] = function()
    header('Cache-Control: max-age=864000')
    sendfile(headers.uri)
end

routes['^/user/:user_id(.*)'] = function(r)
    print('User ID: ', r.user_id)
end

routes['^/(.*)'] = function(r)
    dofile('/index.lua')
end

--[[
others you want :)
]]

if not router(headers.uri, routes) then
    -- try local scripts
    --[[
        /       =>  /index.lua
        /hello  =>  /hello.lua  if not exists then try /hello/index.lua
        /hello/ =>  /hello.lua  if not exists then try /hello/index.lua
    ]]
    local file = headers.uri
    if file:byte(#file) == 47 then -- end with /
        file = file:sub(1, #file - 1)
    end

    if file_exists(file .. '.lua') then
        file = file .. '.lua'
    elseif file_exists(file .. '/index.lua') then
        file = file .. '/index.lua'
    else
        file = nil
    end

    if file and file ~= '/route.lua' then
        dofile(file)
    else
        header('HTTP/1.1 404 Not Found')
        echo('File Not Found!')
    end
end
{'fraction_non_alphanumeric': 0.19225967540574282, 'fraction_numerical': 0.018726591760299626, 'mean_word_length': 2.634920634920635, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '438946', 'n_tokens_mistral': 614, 'n_tokens_neox': 603, 'n_words': 128}