Code Monkey home page Code Monkey logo

Comments (8)

 avatar commented on July 18, 2024

Try this one:

#!/usr/bin/env python                                                         
# -*- coding: utf-8 -*-                                                       

import json                                                                   
import os                                                                     

import requests                                                               


url = 'http://localhost:7272/api/v0.1/{}/push'.format(os.environ('TIPBOARD_API_KEY'))

data_push = dict(                                                             
    tile='text', key='id_1', data=json.dumps({"text":"Hello World"})          
)                                                                             
r = requests.post(url, data=data_push)                                        
print(r.status_code, r.reason) 

Of course, you have to define TIPBOARD_API_KEY as system environment.

from tipboard.

cosbgn avatar cosbgn commented on July 18, 2024

What do you mean with

define TIPBOARD_API_KEY as system environment.

as: os.environ["TIPBOARD_API_KEY"] = "a8e0e4e8f58f4c0aa4f3e9ef2afc73b2" ?

Trying the code I now get an attribute errror: AttributeError: _Environ instance has no __call__ method pointing at the url = ... line.

Thanks for your help!

from tipboard.

 avatar commented on July 18, 2024

Try this version

url = 'http://my_ip:7272/api/v0.1/a8e0e4e8f58f4c0aa4f3e9ef2afc73b2/push'
data_push = dict(                                                             
    tile='text', key='id_1', data=json.dumps({"text":"Hello World"})          
)
r = requests.post(url, data=data_push)
print(r.status_code, r.reason)

It's closer to your way.

from tipboard.

cosbgn avatar cosbgn commented on July 18, 2024

Still (403, 'Forbidden')

from tipboard.

ar4s avatar ar4s commented on July 18, 2024

try following command curl -X POST http://127.0.0.1:7272/api/v0.1/a8e0e4e8f58f4c0aa4f3e9ef2afc73b2/push -d 'tile=text&key=id_1&data={"text": "Hello world"}' from command line

from tipboard.

cosbgn avatar cosbgn commented on July 18, 2024

From the command line I get:

(env) CMac:App cosbgn$ curl -X POST http://192.xxx.x.xx:7272/api/v0.1/a8e0e4e8f58f4c0aa4f3e9ef2afc73b2/push -d 'tile=text&key=id_1&data={"text": "Hello world"}'
Tile's name not found in the configuration file.

and

(env) CMac:App cosbgn$ curl -X POST http://127.0.0.1:7272/api/v0.1/a8e0e4e8f58f4c0aa4f3e9ef2afc73b2/push -d 'tile=text&key=id_1&data={"text": "Hello world"}'
curl: (7) Failed to connect to 127.0.0.1 port 7272: Connection refused

from tipboard.

 avatar commented on July 18, 2024

Tile's name not found in the configuration file.

Make sure that you have something like this:

..
            - tile_template: text                                             
              tile_id: id_1                                                   
..

in ~/.tipboard/layout_config.yaml

from tipboard.

cosbgn avatar cosbgn commented on July 18, 2024

Okey, so I had:

tile_template: empty                                             
      tile_id: empty

I've changed it to:

tile_template: text                                             
      tile_id: id_1   

Now everything is solved! Thanks a lot!

from tipboard.

Related Issues (20)

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.