Skip to content
/ paper Public

Develop applications for Pythonista using web tools.

License

Notifications You must be signed in to change notification settings

10c8/paper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Paper

Develop applications for Pythonista using web tools.

Paper is a library that allows Pythonista users to develop aplications using HTML, CSS and JavaScript.

Usage

Initialize the library:

import paper

# Initialize Paper
app = paper.app('./app')

# Expose the function 'hello' to the JS API
@app.expose
def hello():
    return 'Oh, hi!'

# Run your app
app.run()

Make your app (inside “app” folder):

<!DOCTYPE html>
<html>
<head>
    <title>Paper</title>

    <!-- Paper API -->
    <script src="./jquery.min.js"></script>
    <script src=“./paper.js”></script>
</head>
<body>
    <h1>Hello, Paper!</h1>
    <button onclick=“sayHello()”>Hello!</button>

    <script>
    function sayHello() {
        response = paper.py.hello();
        alert(response);
    }
    </script>
</body>
</html>

Voilá.

Features

Important:

  • Return exceptions to JavaScript instead of crashing the server.
  • Garbage collection for Python objects and references.
  • Good performance when working with heavy data.

Modules:

  • Import Python modules from JavaScript.
  • import x.y

Functions:

  • Convert Python built-in functions to JavaScript functions.
    • Call Python function with kwargs.
  • Convert a JavaScript function to a Python function.

Types:

  • Create JavaScript references of Python objects.
  • Convert basic Python types to JavaScript equivalents (int, float, string, complex, list, dict and tuple).
  • Convert basic JavaScript types to Python equivalents (int, float, string, array and object).
  • Create JavaScript objects from Python objects.
  • Create Python objects from JavaScript objects.

Classes:

  • Create Python class instances using JavaScript.
  • Convert Python class instances to JavaScript objects.
  • Create Python classes using JavaScript.
    • Expand Python classes using JavaScript.

Contribute

Suggestions, as well as pull requests and bug reports are welcome.

License

MIT

About

Develop applications for Pythonista using web tools.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published