Created
June 3, 2022 14:16
-
-
Save yimeng/0ae8cf27bec099af9fd52979fd7616d0 to your computer and use it in GitHub Desktop.
cloud-init-python-http-api
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
| from flask import Flask, jsonify, render_template | |
| app = Flask(__name__) | |
| @app.route("/") | |
| def index(): | |
| return render_template('index.html') | |
| @app.route("/user-data") | |
| def user(): | |
| hostname = "abcdef.com.cn" | |
| return render_template('user-data',hostname=hostname) | |
| @app.route("/meta-data") | |
| def meta(): | |
| return render_template('meta-data') | |
| @app.route("/vendor-data") | |
| def vendor(): | |
| return render_template('vendor-data') | |
| # HTTP 直通函数由于是基于 docker 镜像运行,所以必须监听地址为 0.0.0.0,并且端口为 9000 | |
| app.run(host = '0.0.0.0', port = 9000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment