Coder Social home page Coder Social logo

raspberrypi_api's Introduction

提醒

项目不再维护,推荐使用Remote GPIO Recipes

raspberrypi_api

把树莓派的硬件功能作为web api

原因

  • 近期公司有一个有趣的项目,希望用乐高玩具式的可视化编程工具来操控硬件
  • 树莓派操控硬件需要有root权限,作为服务之后则没有限制
  • 解耦

架构

  • 初期效用flask作为web框架
  • 把led_server视为下位机,api视为指令集

使用

我的树莓派当前ip为:192.168.0.106

启动服务

sudo python led_server.py

控制

可以在浏览器或命令行里打开api接口(动作)

  • 点亮红灯: curl 192.168.0.106/led_up
  • 熄灭红灯: curl 192.168.0.106/led_down
  • 闪啊闪 : curl 192.168.0.106/led_up_down

在网页中用js控制

xmlhttp=new XMLHttpRequest();
xmlhttp.open("GET","http://192.168.0.106/led_up_down",true);
xmlhttp.send();

微信控制

和此前的wechat_bot关联即可

todo

done

  • cors
  • 可以用js控制硬件

raspberrypi_api's People

Contributors

wwj718 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  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.