commoccoom
V2EX  ›  问与答

请教一个问题, web 上的 js 代码如何调用本地的 Python 脚本

  •  
  •   commoccoom · Oct 13, 2020 · 1366 views
    This topic created in 2126 days ago, the information mentioned may be changed or developed.
    想法是,网页界面上有个风扇的开关按钮,切换后调用本地的 python 代码去控制一个风扇硬件的开启。网页是 bootstrap+php
    4 replies    2020-10-13 20:27:13 +08:00
    easonHHH
        1
    easonHHH  
       Oct 13, 2020
    浏览器调用本地的 python 脚本是不行的
    除非你说的是在本地再部署一个服务,开一个接口来实现
    xiangyuecn
        2
    xiangyuecn  
       Oct 13, 2020   ❤️ 1
    python 开 http 端口,网页直接请求接口执行功能就好了,万物皆可转成 http 调用
    commoccoom
        3
    commoccoom  
    OP
       Oct 13, 2020
    @easonHHH
    @xiangyuecn
    好的,感谢。 我琢磨看看
    abersheeran
        4
    abersheeran  
       Oct 13, 2020   ❤️ 1
    把 Python 函数封装成 HTTP 接口就完事了。https://git.io/rpc.py
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   961 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 23:01 · PVG 07:01 · LAX 16:01 · JFK 19:01
    ♥ Do have faith in what you're doing.