Skip to main content

Develop ajax based analytical dashboard without writing any javascript.

Project description

## 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 %}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyajax-0.0.6.tar.gz (2.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyajax-0.0.6-py3-none-any.whl (2.4 kB view details)

Uploaded Python 3

File details

Details for the file pyajax-0.0.6.tar.gz.

File metadata

  • Download URL: pyajax-0.0.6.tar.gz
  • Upload date:
  • Size: 2.3 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for pyajax-0.0.6.tar.gz
Algorithm Hash digest
SHA256 3d2d575128935d9038cd59b3eeeb803417037efe1502d854cfbb9f754b5b76aa
MD5 24ef20844972e31adfb2f783bc1f499f
BLAKE2b-256 4f0ebf113ba94d9c850483c74638d052f53c3052d74a176a3e8c36353810ac05

See more details on using hashes here.

File details

Details for the file pyajax-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: pyajax-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 2.4 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for pyajax-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 e7538d6cb3e70dda2ec240a3f9ce0334008ee5927ca73c540c08155c72c064b0
MD5 cc4c0d4ea5003ffc110052926a70578d
BLAKE2b-256 0e84f1dda92d179e6e2c2eebded7682fcffb6425c17be55bd1fbbb6851744e05

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page