Created
September 15, 2025 14:14
-
-
Save CN-CODEGOD/3793a8445538c8cbee5cebff808be1f5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 利用flask简单做一个API 网页 | |
| 1. | |
| pip install flask | |
| 2. | |
| from flask import Flask | |
| import subprocess | |
| app = Flask(__name__) | |
| @app.route("/run") | |
| def run(): | |
| result = subprocess.getoutput("python3 myscript.py") | |
| return {"output": result} | |
| app.run(host="0.0.0.0", port=8000) | |
| 3. | |
| 运行 python3 server.py | |
| 4. | |
| 在http://(IPaddress):8000/run 即可以查看你的脚本运行 | |
| 用做API 执行 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment