today I want to tell you a little bit more about the script that I’ve got running (had help by @emrebeyler to get it running) for my lametric device that dayle bought me for christmas, while these things are not cheap I really love the idea that you can develop easily for them and that you can string them together for a longer scrolling panel, I’d love another three of them to really see that effect, that’s when scrolling would really be neat.
so then the script, after running the script manually it goes away to grab the coincapmarket information and updates the device via their api, it’s a manual process running on my local machine, obviously I want to automate that so it updates ideally every minute to keep everything up to date, I could probably go even more regular than that but for now I think sixty seconds is enough — I therefore need a python host that can host that simple script for me without any of the other usual stuff to worry about.
Step forward then pythonanywhere a super powerful but simple service that offers the ability to host your python based scripts — I didn’t want to be worrying about managing a full on cloud instance I just wanted to have a service that did one thing and did it well, these guys seem to be perfect with a great dashboard, consoles, file manager, web hosting and most importantly tasks — out of the box it was blocking the access on the free account to the lametric api but they whitelisted the access to it so I can see it working on the free account, that’s great customer service.
Right now on the free account I can run that script daily but for $5 a month I can run it how often I want, ideally it’s going to be in minutes and the best thing is that I should be able to easily duplicate the script to pull in the steem price as well, build another frame on the display of the lametric device and have them cycle between the prices — that’s pretty rad right? :)
the price ticker code for lametric time
I’ve included a copy of the really simple script below, I’m not a coder so the notes are for me and I realise that parts of the error code are a bit clunky if they don’t bring back that result, that it drops through and prints the message regardless, like I’ve said before i’m not a coder so all of this is a learning curve for me.
Again, thank you to @emrebeyler who helped out take my basic lookup api call and turning it into something useable, steem is really amazing that I can blog about that and wishing three hours someone jumped in and wanted to help me get up and running, it’s certainly pushing me to take a course this year in some coding even thou I’m not really a coder or have ever been interested in making things on the backend side.
# url starting with https://developer.lametric.com/api/v1
# remember every publish you get a new URL and TOKEN (also check the icon if you change that and frames)
URL = "https://developer.lametric.com/api/v1/<your-url-here>"
# access token
ACCESS_TOKEN = "the-access-token-for-the-app"
def push_price():
data = requests.get(
"https://api.coinmarketcap.com/v1/ticker/steem-dollars/").json()
headers = {
'Accept': 'application/json',
'X-Access-Token': ACCESS_TOKEN,
'Cache-Control': 'no-cache',
}
r = requests.post(URL, json={
"frames": [{
"text": data[0]["price_usd"],
"icon": "a16407",
"index": 0
}]
}, headers=headers)
if r.status_code == '200':
print("Sent!")
else:
print("- steemit.com/@teamhumble")
print(r.text)
push_price()
next things to do with the script
I’m going to duplicate this and grab the steem price and build another frame in the app maker which is part of the lametric website, it changes the code so I’ll have to change the code in the script to make sure that it’s receiving the correct information because of the second panel (which will effect the first script as well) and ideally I’d like to have the two scripts build into one, I’m wondering if I can just make another def array and then call it the same way, something to play with anyway — oh also, I’ll be making the application then public instead of private because the script will be hosted in the cloud so everyone with a lametric will be able to check the price of steem and sbd too ;) — pretty neat.
i was thinking of recording a video or audio next time to step you through all the parts if anyone is interested in that? it means setting up my tabs and explaining things as non-techy as possible but i thought it might be interesting to those people that might want to learn alongside with me?
wow, Pythonanywhere looks neat. Never heard of it before.
Congrats for the progress. :)
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
right, cool little services. wanna work together again soon? cheers!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Happy to help.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
That's really cool! I'd like to put one of those on my desk lol
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
yeah they work pretty great.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
maybe if i had money i would give it a try
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
well sure, that's like anything in life right? :) i was given this as a gift. it works great.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
YAS! Love being able to see the price of SBD without opening an app anywhere, BAM it's there!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
i like your all post... i wish you alwys..thank you
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit