Skip to main content
## About This
As a datascientist you may dont want to write any javascript. This will help you to build ajax callback without writing any javascript. Script is very simple and too small and works like a charm.

I build this script to plot graph dynamically using ajax but you can use this for anything you need for ajax call.

## Flask integration
### app.py
from flask import Flask, jsonify, render_template, request, url_for
import pyajax

app = Flask(__name__)

@app.route("/")
def index():
config = [{
'handler':{
'event':{'url':'/ajaxname','target':'submit','method':'click'},
'input':{'name':'name'},
'action':{'output':'output'}
}
}]
script = pyajax.buildscript(config)
return render_template('myname.html', script=script)

@app.route("/ajaxname")
def ajaxname():
return jsonify(output=request.args.get('name'))

if __name__ == '__main__':
app.run()

### layout.html

<!doctype html>
<html lang="en">
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
{% block javascript %}{% endblock %}
</head>
<body>
{% block content %}{% endblock %}
</body>
</html>

### myname.html
{% extends 'layout.html'%}

{% block content %}
<div><input type="text" id="name" /> <input type="submit" id="submit" value="submit"/></div>
<div>My Name: <span id="output">?</span></div>
{% endblock %}

{% block javascript %}
{{ script|safe }}
{% endblock %}

Release files for pyajax 0.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyajax 0.0.6
File Size Uploaded
pyajax-0.0.6.tar.gz 2.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyajax 0.0.6
File Interpreter ABI Platform
pyajax-0.0.6-py3-none-any.whl Python 3 none any Details

Total release size: 4.8 kB

Release files / pyajax-0.0.6.tar.gz

Download URL pyajax-0.0.6.tar.gz
Size 2.3 kB
Tags Source
SHA-256 checksum
How to use checksums
3d2d575128935d9038cd59b3eeeb803417037efe1502d854cfbb9f754b5b76aa
BLAKE2b-256 checksum
How to use checksums
4f0ebf113ba94d9c850483c74638d052f53c3052d74a176a3e8c36353810ac05
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.5

Release files / pyajax-0.0.6-py3-none-any.whl

Download URL pyajax-0.0.6-py3-none-any.whl
Size 2.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e7538d6cb3e70dda2ec240a3f9ce0334008ee5927ca73c540c08155c72c064b0
BLAKE2b-256 checksum
How to use checksums
0e84f1dda92d179e6e2c2eebded7682fcffb6425c17be55bd1fbbb6851744e05
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.5

Release history Release notifications | RSS feed

This release

0.0.6 This release

2 release files

0.0.5

2 release files

0.0.4

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page