#!/usr/bin/env perl use Mojolicious::Lite; use 5.010; my %Actions = ( location => [ { area => 'Engressia', 'time' => '2387', x => '46.7369918823242', y => '83.1452331542969', user => '12983', button => 'False', }, ], speakers => [ { name => 'Johnny', bio => 'Johnny\'s bio' }, { name => 'Judas', bio => 'Judas\'s bio' }, ], talks => [ { speakers => [ 'Judas', 'JohnnyX' ], title => 'Ancient Egyptian Music and DRM', abstract => 'A discussion of the development of musical notation, which was designed as a means of reproducing music while making it impossible for the general public to perform without permission.', 'time' => '2008/7/18 13:00:00', track => 'Hooper', interests => [ 'media', 'crypto' ] }, ], interests => [ 'new tech', 'activism', 'radio', 'lockpicking', 'crypto', 'privacy', 'ethics', 'telephones', 'social engineering', 'hacker spaces', 'hardware hacking', 'nostalgia', 'communities', 'science', 'government', 'network security', 'malicious software', 'pen testing', 'web', 'niche hacks', 'media' ], users => [ { name => 'JohnnyX', x => '32.54091324', y => '54.10958384', interests => [ 'new tech', 'radio', 'lockpicking', 'crypto', 'telephones', 'social engineering', 'hacker spaces', 'hardware hacking', 'nostalgia', 'communities', 'science', 'network security', 'malicious software', 'pen testing', ], }, { name => 'andrew', x => '32', y => '54', interests => [ 'media', 'lockpicking', 'crypto', 'telephones', 'social engineering', 'hacker spaces', 'hardware hacking', 'science', 'network security', 'malicious software', 'pen testing', ], }, { name => 'Judas', x => '33', y => '52', interests => [ 'media', 'lockpicking', 'crypto', 'telephones', 'social engineering', 'science', 'network security', 'malicious software', 'pen testing', ], }, ], ); get '/' => 'index'; get '/api/:action' => sub { my $self = shift; my $action = $self->stash('action'); return if !exists $Actions{$action}; my @data = @{ $Actions{$action} }; foreach my $param ( $self->param() ) { next if $param eq 'callback'; next if $param eq 'action'; my $value = $self->param($param); @data = grep $value ~~ $_->{$param}, @data; } $self->render_json( \@data ); }; app->start; __DATA__ @@ index.html.ep % layout 'default'; Please try /api/action @@ layouts/default.html.ep Test OpenAMD API! <%== content %>