FROM python:3.7
COPY ./src /data/python
WORKDIR /data/python
RUN pip install --no-cache-dir flask
EXPOSE 8080
CMD ["python", "main.py"]
- 主文件
import os
from flask import Flask
app = Flask(__name__)
@app.route('/')
def index():
return {'body': os.environ.items()}
def run():
app.run(host='0.0.0.0', port=8080)
if __name__ == '__main__':
run()
点击调用结果
[
"2021-01-29T09:53:30.727847Z stdout: * Serving Flask app \"main\" (lazy loading)",
"2021-01-29T09:53:30.727905Z stdout: * Environment: production",
"2021-01-29T09:53:30.727913Z stdout: WARNING: This is a development server. Do not use it in a production deployment.",
"2021-01-29T09:53:30.727918Z stdout: Use a production WSGI server instead.",
"2021-01-29T09:53:30.727923Z stdout: * Debug mode: off",
"2021-01-29T09:53:30.731130Z stderr: * Running on http://0.0.0.0:8080/ (Press CTRL+C to quit)",
"2021-01-29T09:53:30.747035Z stderr: 172.30.139.167 - - [29/Jan/2021 09:53:30] \"\u001b[33mPOST /init HTTP/1.1\u001b[0m\" 404 -",
"2021-01-29T09:53:30.748Z stderr: The action did not initialize or run as expected. Log data might be missing."
]
我已将 Docker 容器添加到 IBM Cloud Functions
解决这个问题的最佳方法是什么?