Comments (9)
@Oliv4945 you are right there is a bug, and not a small one
I noticed that in the browser (with GET
parameters) it's not working:
http://192.168.1.20:8080/?order=bonjour&mute=false&verbose=false
# will be mute and verbose
Need to fix this.
However, Jarvis-UI sends true
or false
in the parameters and it works. I think this is because the data is sent with POST
and in the python
code evaluates that boolean with the parenthesis (with POST
it is apparently not a string but a real boolean):
jarvis.mute_mode = ("mute" in data) and (data ["mute"])
jarvis.verbose = ("verbose" in data) and (data ["verbose"])
As a workaround for your App, can you make the requests with POST
? If not, is "true" and "false" as values for GET
ok for you?
from jarvis-api.
think this is because the data is sent with POST and in the python code evaluates that boolean with the parenthesis (with POST it is apparently not a string but a real boolean):
With a GET request you can only send strings. With POST request, Python parse data as a JSON object, so a boolean:
{"key": "testkey", "mute": true, "verbose":false}
As a workaround for your App, can you make the requests with POST
Already published here, I am not sending "mute" if not required.
By the way I already use a POST request but I was sending a string instead of a Boolean :$
from jarvis-api.
Okay. I will hardcode a check if string and not equal "false".
from jarvis-api.
So a way to go might be (not tested)
mute = data.get("mute", False)
if isinstance(mute, str)
if mute.lower() == 'true':
mute = True
else:
mute = False
jarvis.mute_mode = mute
from jarvis-api.
I did more or less the same (saw your message after commit):
if "mute" in data:
mute=data["mute"]
jarvis.mute_mode=mute if isinstance(mute, bool) else (mute != "false")
from jarvis-api.
Ok, you should put lower() in case somebody send the string False
if "mute" in data:
mute=data["mute"]
jarvis.mute_mode=mute if isinstance(mute, bool) else (mute.lower() != "false")
Just by curiosity, why don't you put mute == 'true'
instead ?
from jarvis-api.
@Oliv4945 yes I could but the API docs says "true", and I always prefer to keep the code as simple as possible. But I could change here no big deal if it's easier for you.
Now why != false
and not == true
I think it's more of a philosophical question
Maybe coding influence where everything that is not really "false" is true.
from jarvis-api.
@Oliv4945 yes I could but the API docs says "true", and I always prefer to keep the code as simple as possible. But I could change here no big deal if it's easier for you.
It does not change anything for me but be prepared to have an issue one day or another, always take the place of a fool and see what can go wrong :p
Maybe coding influence where everything that is not really "false" is true.
Ok, funny thing because for me what is not explicitly true is false :-)
from jarvis-api.
You won
from jarvis-api.
Related Issues (20)
- JSON API is not consistent HOT 2
- Jarvis-API does not trigger hooks ? HOT 8
- {"error": "RESTRequestHandler instance has no attribute 'say'"} HOT 5
- Retour en erreur sur certaines commandes. HOT 4
- Jarvis API HOT 7
- erreur 13 ...Permission denied HOT 1
- Question technique svp HOT 2
- Ne fonctionne pas avec jarvis-web-answers HOT 1
- Ne fonctionne pas en mode conversation
- Expecting , delimiter
- No JSON object could be decoded HOT 1
- API bloque le mode écoute
- {"error": "[Errno 2] No such file or directory"} HOT 1
- Jarvis ne détecte pas toujours qu'il est déjà lancé - du coup il plante micro car micro occupé HOT 9
- Sécurisation de l'API par token HOT 1
- IP is empty: Starting RestAPI server on http://:8080 HOT 9
- API & Commandes imbriquées : précisions et.ou évolution possible ... HOT 10
- Problème Jarvis-API ne reconnais pas les commandes HOT 1
- Problème avec Jarvis-API HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jarvis-api.