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 %}
Metadata
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)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyajax-0.0.6.tar.gz | 2.3 kB | Without provenance | Details for pyajax-0.0.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyajax-0.0.6-py3-none-any.whl | Python 3 | none | any | Details for pyajax-0.0.6-py3-none-any.whl |
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
|
Security for pyajax 0.0.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.