flask/examples/javascript
Grey Li ef434ea998
Replace old pocoo links everywhere
pocco.org -> palletsprojects.com
2019-11-19 09:32:35 -08:00
..
js_example apply reorder-python-imports pre-commit config 2019-06-01 09:07:20 -07:00
tests apply reorder-python-imports pre-commit config 2019-06-01 09:07:20 -07:00
.gitignore add javascript ajax example 2018-04-12 11:06:02 -07:00
LICENSE add javascript ajax example 2018-04-12 11:06:02 -07:00
MANIFEST.in add javascript ajax example 2018-04-12 11:06:02 -07:00
README.rst Replace old pocoo links everywhere 2019-11-19 09:32:35 -08:00
setup.cfg add javascript ajax example 2018-04-12 11:06:02 -07:00
setup.py Replace old pocoo links everywhere 2019-11-19 09:32:35 -08:00

README.rst

JavaScript Ajax Example
=======================

Demonstrates how to post form data and process a JSON response using
JavaScript. This allows making requests without navigating away from the
page. Demonstrates using |XMLHttpRequest|_, |fetch|_, and
|jQuery.ajax|_. See the `Flask docs`_ about jQuery and Ajax.

.. |XMLHttpRequest| replace:: ``XMLHttpRequest``
.. _XMLHttpRequest: https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest

.. |fetch| replace:: ``fetch``
.. _fetch: https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch

.. |jQuery.ajax| replace:: ``jQuery.ajax``
.. _jQuery.ajax: https://api.jquery.com/jQuery.ajax/

.. _Flask docs: https://flask.palletsprojects.com/patterns/jquery/


Install
-------

::

    $ python3 -m venv venv
    $ . venv/bin/activate
    $ pip install -e .


Run
---

::

    $ export FLASK_APP=js_example
    $ flask run

Open http://127.0.0.1:5000 in a browser.


Test
----

::

    $ pip install -e '.[test]'
    $ coverage run -m pytest
    $ coverage report