Redistribution and use in source and binary forms of the software as well
as documentation, with or without modification, are permitted provided
that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Flask-Web3 nor the names of the contributors may not be used to endorse or
promote products derived from this software without specific
prior written permission.
THIS SOFTWARE AND DOCUMENTATION IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE AND DOCUMENTATION, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
Description: .. image:: https://travis-ci.org/nmvalera/flask-web3.svg?branch=master
:target: https://travis-ci.org/nmvalera/flask-web3
:alt: Build Status
.. image:: https://codecov.io/gh/nmvalera/flask-web3/branch/master/graph/badge.svg
:target: https://codecov.io/gh/nmvalera/flask-web3
:alt: Coverage
.. image:: https://readthedocs.org/projects/flask-web3/badge/?version=stable
:target: https://flask-web3.readthedocs.io/en/stable/?badge=stable
:alt: Documentation Status
Flask-Web3
==========
Flask-Web3 is a flask extension allowing to smoothly integrate a flask application with `web3.py`_.
This package is intended for developers will to build a Flask application that interacts with an Ethereum client.
.. _`web3.py`: https://github.com/ethereum/web3.py
Requirements
~~~~~~~~~~~~
- Python>=3.5
A simple example
~~~~~~~~~~~~~~~~
.. code-block:: python
>>> from flask import Flask, jsonify
>>> from flask_web3 import current_web3, FlaskWeb3
# Declare Flask application
>>> app = Flask(__name__)
# Set Flask-Web3 configuration
>>> app.config.update({'ETHEREUM_PROVIDER': 'http', 'ETHEREUM_ENDPOINT_URI': 'http://localhost:8545'})
# Declare Flask-Web3 extension
>>> web3 = FlaskWeb3(app=app)
# Declare route
>>> @app.route('/blockNumber')
... def block_number():
... return jsonify({'data': current_web3.eth.blockNumber})
You can notice that Flask-Web3 gives you an application context bound variable ``current_web3`` that is accessible
from any active flask application context.
An advanced example
~~~~~~~~~~~~~~~~~~~
You may like to declare your Flask-Web3 extension from a customize Web3 class with enhanced logic.
.. code-block:: python
>>> from flask import Flask, jsonify
>>> from flask_web3 import current_web3, FlaskWeb3
>>> from web3 import Web3
# Declare Flask application
>>> app = Flask(__name__)
>>> app.config.update({'ETHEREUM_PROVIDER': 'http', 'ETHEREUM_ENDPOINT_URI': 'http://localhost:8545'})
# Declare a custom Web3 class
>>> class CustomWeb3(Web3):
... def customBlockNumber():
... return self.eth.blockNumber
# Associate a custom FlaskWeb3 extension
>>> class CustomFlaskWeb3(FlaskWeb3):
... web3_class = CustomWeb3
# Declare customized web3 extension
>>> web3 = CustomFlaskWeb3(app=app)
>>> isinstance(web3, CustomWeb3)
True
# Declare route
>>> @app.route('/customBlockNumber')
... def last_odd_block_number():
... return jsonify({'data': current_web3.customBlockNumber()})
Documentation
~~~~~~~~~~~~~
Full documentation is available at https://flask-web3.readthedocs.io/en/stable/.
Platform: any
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Provides-Extra: doc
Provides-Extra: dev
Metadata
Release files for Flask-Web3 0.1.1
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 |
|---|---|---|---|---|
| Flask-Web3-0.1.1.tar.gz | 11.2 kB | Without provenance | Details for Flask-Web3-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| Flask_Web3-0.1.1-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for Flask_Web3-0.1.1-py2.py3-none-any.whl |
Total release size: 21.9 kB
Release files / Flask-Web3-0.1.1.tar.gz
| Download URL | Flask-Web3-0.1.1.tar.gz |
|---|---|
| Size | 11.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
040dcae3ffb093b70aa8f20bb20a7c93e157726c93e3162605aa1c4c17ae8554
|
|
BLAKE2b-256 checksum How to use checksums |
aa7a26a40f964770e0b1bede013e13643796f191e9764378a3dfb027056e25a7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / Flask_Web3-0.1.1-py2.py3-none-any.whl
| Download URL | Flask_Web3-0.1.1-py2.py3-none-any.whl |
|---|---|
| Size | 10.8 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
b3ea686a3903cf709032175f25f63aad3d5c94de13d9e96ab0b31fb9090214cf
|
|
BLAKE2b-256 checksum How to use checksums |
d736379be40408f17ad52d22301e0619c8e737d6d20d1cba38d8ab61770953ec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for Flask-Web3 0.1.1
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.