Editing API
Jump to navigation
Jump to search
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 15: | Line 15: | ||
For instance, to open the door using curl: | For instance, to open the door using curl: | ||
<source lang="bash"> | <source lang="bash"> curl -X POST -d open=True http://api.noisebridge.net/gate/</source> | ||
</source> | |||
=== GET /hello/[name] === | === GET /hello/[name] === | ||
Line 32: | Line 26: | ||
=== GET /gate/ === | === GET /gate/ === | ||
Gets interesting | Gets interesting stats about the gate. Currently: | ||
<pre class="json"> { | <pre class="json"> { | ||
Line 38: | Line 32: | ||
}</pre> | }</pre> | ||
Where 'ringing' is true if the gate buzzer is ringing at that moment, or in the last few seconds, as users may push the button for a very short time. The amount of time that this state is cached is totally up to the Gateman daemon that runs to interact with the gate hardware. | Where 'ringing' is true if the gate buzzer is ringing at that moment, or in the last few seconds, as users may push the button for a very short time. The amount of time that this state is cached is totally up to the Gateman daemon that runs to interact with the gate hardware. | ||
=== POST /gate/ === | === POST /gate/ === | ||
Line 52: | Line 44: | ||
Note that this isn't a required field. Currently if you omit the key field, the door will always open. It's intended to optionally allow other apps to offer the same door code authentication that we use for the phone booth entry. | Note that this isn't a required field. Currently if you omit the key field, the door will always open. It's intended to optionally allow other apps to offer the same door code authentication that we use for the phone booth entry. | ||
=== POST /audio/ === | === POST /audio/ === | ||
Line 104: | Line 55: | ||
Just add a function of the form: | Just add a function of the form: | ||
<source lang="python"> | <source lang="python">@api_app.route("/myurl/") | ||
@api_app.route("/myurl/") | |||
def myfunc() | def myfunc() | ||
do_something_in_the_space() | do_something_in_the_space() | ||
return { 'success' : True, 'OMG IT WORXORRED' } | return { 'success' : True, 'OMG IT WORXORRED' }</source> | ||
</source> | |||
== Deploying your new API == | == Deploying your new API == | ||
You'll need sudo powers on | You'll need sudo powers on pony. Check out the code using git: | ||
<source lang="bash"> | <source lang="bash"> git clone /var/local/noise_api/</source> | ||
</source> | |||
Make your changes, and test them locally using | Make your changes, and test them locally using | ||
<source lang="bash"> | <source lang="bash"> python api.py --debug</source> | ||
python api.py --debug | When you're ready to deploy, commit the code, then pull it out to the runningversion of api.py. | ||
</source> | |||
When you're ready to deploy, | |||
<source lang="bash"> | <source lang="bash"> cd /var/local/noise_api/ | ||
sudo git pull [your cloned directory goes here] | |||
sudo make install</source> | |||
</source> |