我正在使用一个简单的Flask应用程序,因为我正在使用dafault模板:
ListBoxItem
我只是调用一个返回并“确定”响应的伪函数:
GridView
当我直接在计算机上使用以下代码调用它时:
ContentPresenter
它可以正常工作,但是如果我从docker映像运行它,则会出现以下错误:
from flask import render_template
import connexion
# Create the application instance
app = connexion.App(__name__, specification_dir="./")
# read the swagger.yml file to configure the endpoints
app.add_api("swagger.yml")
# Create a URL route in our application for "/"
@app.route("/")
def home():
"""
This function just responds to the browser URL
localhost:5000/
:return: the rendered template "home.html"
"""
return render_template("home.html")
if __name__ == "__main__":
app.run(debug=True)
这是我正在使用的docker文件:
def test(features):
return 'ok'
我正在使用相同的5000端口:
headers = {'content-type': 'application/json'}
#url = "http://localhost:5000/api/document"
url = "http://localhost:5000/api/scraping"
data = {'features':features}
response = requests.post(url,data=json.dumps(data), headers=headers )
答案 0 :(得分:2)
您需要expose
中的5000
端口Dockerfile
:
FROM ubuntu:18.04
RUN apt-get update -y && \
apt-get install -y python-pip python-dev
# We copy just the requirements.txt first to leverage Docker cache
COPY ./requirements.txt /app/requirements.txt
WORKDIR /app
RUN pip install -r requirements.txt
COPY . /app
EXPOSE 5000
ENTRYPOINT [ "python" ]
CMD [ "app.py" ]