运行server.py文件时出错
File "C:\Users\nawin\AppData\Local\Programs\Python\Python38\lib\site-packages\starlette\staticfiles.py", line 57, in __init__
raise RuntimeError(f"Directory '{directory}' does not exist")
RuntimeError: Directory 'app/static' does not exist
server.py文件
app = Starlette()
app.add_middleware(CORSMiddleware, allow_origins=['*'], allow_headers=['X-Requested-With', 'Content-Type'])
app.mount('/static', StaticFiles(directory='app/static'))
python版本3.8 操作系统windows 10
了解程序的执行路径非常重要(对于GNU/Linux环境):
如果您有这样一个工作目录:
~/working/myprogram
第一例
cd ~/working/myprogram
python3 mysuper.py
然后您可以毫无问题地执行
第二种情况
但如果您在另一个目录中:
cd ~/Desktop
python3 ~/working/myprogram/mysuper.py
在第二种情况下,您将遇到问题。为了避免这种情况,有一个建议(很难看),但可以是:
相关问题 更多 >
编程相关推荐