send_from_directory() missing 1 required positional argument: 'path'?/
时间: 2023-08-18 10:20:28 浏览: 64
The error message "send_from_directory() missing 1 required positional argument: 'path'" usually occurs when you call the send_from_directory function without providing the required argument 'path'. This function is used to send files from a directory to a client, and it requires two arguments: the directory path and the filename.
To fix this error, make sure that you provide the correct path to the directory containing the file you want to send. For example, if your file is located in the directory "/var/www/static", you should call the function as follows:
```
from flask import send_from_directory
@app.route('/download/<path:filename>')
def download_file(filename):
return send_from_directory('/var/www/static', filename)
```
In this example, the first argument to send_from_directory is the directory path "/var/www/static", and the second argument is the filename passed as a dynamic parameter in the route decorator.
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)