Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
从网页端控制 feeluown 示例
- pip3 install flask # 安装依赖
- python3 # 启动网页,在浏览器
import socket
from flask import Flask, request
app = Flask(__name__)
index_html = """
<form method="POST" action="/exec">
<input name="cmd" style="width: 400px; height: 30px;" placeholder="输入命令,比如 `play fuo://netease/songs/25704014`" />
<input type="submit" />
def index():
return index_html
@app.route('/exec', methods=["POST"])
def exec_cmd():
cmd = request.form.get('cmd') or 'help'
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(('', 23333))
sock.recv(1024 * 10)
sock.sendall(bytes(cmd, 'utf-8') + b'\n')
content = sock.recv(1024 * 10)
return index_html.format(content.decode('utf-8'))'', port=9000, debug=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.