Advertisement
Guest User

Untitled

a guest
Dec 18th, 2014
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. #!/usr/bin/env perl
  2.  
  3. package HelloWord;
  4. use Web::Simple;
  5.  
  6. use JSON::XS;
  7. use Digest::MD5 qw/md5_hex/;
  8. sub dispatch_request{
  9. sub(POST + /mobile/login){
  10. [200, ['Content-type', 'application/json'],[encode_json( {
  11. api_key => md5_hex(rand),
  12. nome => "Teste Fake",
  13.  
  14. tipo => "PF",
  15. id => "288",
  16. sexo => "F"
  17.  
  18. }) ] ]
  19. },
  20. sub(POST + /mobile/logout){
  21. [200, ['Content-type', 'application/json'],[encode_json( {
  22. ok => 1
  23. }) ] ]
  24. },
  25. sub(POST + /mobile/log){
  26. [200, ['Content-type', 'application/json'],[encode_json( {
  27. ajudometro => '140354,00'
  28. }) ] ]
  29. },
  30. sub(GET + /mobile/ofertas){
  31. [200, ['Content-type', 'application/json'],[encode_json( {
  32. linhas => [
  33. { imagem_icone => 'http://i.imgur.com/D0NzvKH.png',
  34. imagem_pequena => 'http://i.imgur.com/D0NzvKH.png',
  35. imagem_media => 'http://i.imgur.com/D0NzvKH.png',
  36. imagem_grande => 'http://i.imgur.com/D0NzvKH.png',
  37. url_compra => 'http://google.com/',
  38. preco_cheio => '10,00',
  39. preco_promocional => '9,80',
  40. nome => 'Titulo',
  41. descricoes => [
  42. {
  43. titulo => 'Nonono',
  44. conteudo => 'zooo',
  45. },
  46. {
  47. titulo => 'abc',
  48. conteudo => 'wwwo',
  49. },
  50. ]
  51. }
  52. ]
  53. }) ] ]
  54. },
  55. sub(GET + /mobile/ajudometro){
  56. [200, ['Content-type', 'application/json'],[encode_json( {
  57. ok => 1
  58. }) ] ]
  59. },
  60. sub(){
  61. [405, ['Content-type', 'text/plain'],['Method not allowed'] ]
  62. }
  63. }
  64.  
  65. HelloWord->run_if_script;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement