Giter Site home page Giter Site logo

chainlink-python's Introduction

Chainlink Python Sample

A simple python app using web3.py and Web3.py Chainlink library

Requirements

Create the project

Create a project folder and create a virtual environment and activate it.

mkdir flask-hello-world && cd $_
python3 -m venv .venv
source .venv/bin/activate

Install Flask

First create a file to save dependencies (only Flask dependency in this case).
The must common name for this file is requirements.txt, so:

touch requirements.txt

Now you need to define your dependencies, and the file looks like this:

flask==1.1.2

You can check Flask releases in: https://github.com/pallets/flask/releases.
To install it, you just to need run:

pip install -r requirements.txt

Now, you can check installed dependencies (Flask and its dependencies).

pip freeze

And the output should be like this:

click==7.1.2
Flask==1.1.2
itsdangerous==1.1.0
Jinja2==2.11.2
MarkupSafe==1.1.1
Werkzeug==1.0.1

WOW Flask has very few dependencies to be a web application framework,
it is because Flask is a microframework

Run your new app

To run your app, first you need to set a environment variable called FLASK_APP
and its value is the name of your file where your app is (main.py in this case).
Optionally you can set the debug mode for developing suing FLASK_DEBUG env var to 1.

export FLASK_APP=main.py
export FLASK_DEBUG=1

Check the env var:

echo $FLASK_APP
$ main.py

And then you can run your app:

flask run

And it outputs something like:

* Serving Flask app "main.py"
* Environment: production
  WARNING: This is a development server. Do not use it in a production deployment.
  Use a production WSGI server instead.
* Debug mode: on
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

By default Flask app run a server in the 5000 port in localhost.
Now you can send a request to your app:

curl http://127.0.0.1:5000/

The output should be like:

Hello world with Flask

To stop your new app, just press CTRL + c

License

MIT. Copyright (c)

chainlink-python's People

Contributors

danielgruesso avatar gamadorh avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.