-
-
Save aanoaa/4284052 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Page Title</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1" charset="utf-8"> | |
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script> | |
<script src="./app.js"></script> | |
</head> | |
<body> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Generated by CoffeeScript 1.4.0 | |
(function() { | |
$(function() { | |
return $.ajax({ | |
url: 'http://localhost:5000', | |
type: 'GET', | |
headers: { | |
Authorization: 'abcde:12345' | |
}, | |
success: function(data, textStatus, jqXHR) { | |
console.log(data); | |
return console.log(textStatus); | |
} | |
}); | |
}); | |
}).call(this); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my $app = sub { | |
my $env = shift; | |
my ($code, $headers, $body) = ('200', [], []); | |
if ($env->{REQUEST_METHOD} eq 'GET') { | |
push @$headers, 'Content-Type'; | |
push @$headers, 'text/plain'; | |
$body = ['hello world']; | |
} elsif ($env->{REQUEST_METHOD} eq 'OPTIONS') { | |
push @$headers, 'Content-Length'; | |
push @$headers, '0'; | |
push @$headers, 'Access-Control-Allow-Origin'; | |
push @$headers, '*'; | |
push @$headers, 'Access-Control-Allow-Headers'; | |
push @$headers, 'Authorization'; | |
push @$headers, 'Access-Control-Allow-Methods'; | |
push @$headers, 'GET, POST, PUT, OPTIONS'; | |
push @$headers, 'Access-Control-Max-Age'; | |
push @$headers, '86400'; | |
} | |
return [ | |
$code, | |
$headers, | |
$body | |
]; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~/Desktop $ plackup app.psgi | |
HTTP::Server::PSGI: Accepting connections at http://0:5000/ | |
127.0.0.1 - - [12/Dec/2012:22:07:39 +0900] "OPTIONS / HTTP/1.1" 200 - "-" "Mozilla/5.0 (X11; Linux x86_64; rv:10.0.11) Gecko/20100101 Firefox/10.0.11 Iceweasel/10.0.11" | |
127.0.0.1 - - [12/Dec/2012:22:07:39 +0900] "GET / HTTP/1.1" 200 11 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:10.0.11) Gecko/20100101 Firefox/10.0.11 Iceweasel/10.0.11" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment