HSE-NN-SE / heroku_flask_app-ImOsMa

heroku_flask_app-ImOsMa created by GitHub Classroom

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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: http://flask.pocoo.org/docs/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

About

heroku_flask_app-ImOsMa created by GitHub Classroom

License:Other


Languages

Language:HTML 60.6%Language:Python 34.7%Language:Dockerfile 4.8%