the way for employment, I've been studying docker. I built container from dockerfile
, and got ValueError
when I run a container message says I wrote wrong urls, but I have no idea how could I fix.
I got this message from log:
Traceback (most recent call last):
File "/echo/docker_test.py", line 6, in <module>
def hello():
File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1315, in decorator
self.add_url_rule(rule, endpoint, f, **options)
File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 98, in wrapper_func
return f(self, *args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1275, in add_url_rule
rule = self.url_rule_class(rule, methods=methods, **options)
File "/usr/local/lib/python3.9/site-packages/werkzeug/routing.py", line 666, in __init__
raise ValueError("urls must start with a leading slash")
ValueError: urls must start with a leading slash
And this is my docker_test.py:
from flask import Flask, request
app=Flask(__name__)
@app.route('/hi/')
def hi():
mth=request.method
print("hello world")
return "hello world"
if __name__ == '__main__':
app.run(host='127.0.0.1', port=5000)
'''
Dockerfile:
FROM python:3.9
RUN pip install flask
RUN mkdir /echo
COPY docker_test.py /echo
CMD ["python", "/echo/docker_test.py"]
and my development environment:
docker : 20.10.2
python : 3.9
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…