Pico: Simple Python HTTP APIs

Release v2.0.0. (Installation)

Pico is a very small HTTP API framework for Python. It enables you to write HTTP APIs with minimal fuss, overhead and boilerplate code.

example.py
 import pico
 from pico import PicoApp

 @pico.expose()
 def hello(who="world"):
     s = "hello %s!" % who
     return s


 @pico.expose()
 def goodbye(who):
     s = "goodbye %s!" % who
     return s


 app = PicoApp()
 app.register_module(__name__)

Start the development server:

python -m pico.server example

Call your http api functions from with any http client:

curl http://localhost:4242/example/hello/
curl http://localhost:4242/example/hello/?who="fergal"
curl http://localhost:4242/example/goodbye/?who="fergal"

Use the Javascript client.

index.html
<!DOCTYPE HTML>
<html>
<head>
  <title>Pico Example</title>
    <!-- Load the pico Javascript client, always automatically available at /pico.js -->
    <script src="/pico.js"></script>
     <!-- Load our example module -->
    <script src="/example.js"></script>
</head>
<body>
  <p id="message"></p>
  <script>
  example.hello("Fergal").then(function(response){
    document.getElementById('message').innerHTML = response;
  });
  </script>
</body>
</html>

Features

  • Automatic URL routing
  • Decorators
  • Automatic JSON serialisation
  • Automatic argument parsing & passing
  • Simple streaming responses
  • Development server with debugger
  • WSGI Compliant
  • Built upon Werkzeug
  • Python Client
  • Javascript Client

Installation

Simply install with pip:

pip install -U pico

Acknowledgements

Pico development is kindly supported by Hipo.