대 코드를 디버거를 가져 오류를 위해 노력하는 동안 플라스크에 디버깅용

0

질문

나는 현재 플라스크 응용 프로그램에서는 파일의 구조는 다음과 같습니다.

C:\Users\kmelton\Python\Flask\BGSCS-API-dev\InterjectApi\server.py

그리고 폴더가 현재 열려 있으로 작업 공간에 대 코드 BGSCS-API-dev 폴더에 있습니다.

내 실행합니다.json 는 현재 다음과 같다:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Flask",
            "type": "python",
            "request": "launch",
            "module": "flask",
            "env": {
                "FLASK_APP": "server.py",
                "FLASK_ENV": "development"
            },
            "args": [
                "run",
                "--no-debugger"
            ],
            "jinja": true
        }
    ]
}

과에 따라 모든 디버깅을 시도,나는 오류가 발생합니다.

 * Serving Flask app 'server.py' (lazy loading)
 * Environment: development
 * Debug mode: on
Usage: python -m flask run [OPTIONS]
Try 'python -m flask run --help' for help.

Error: Could not import 'server'.

내가 알고 있는 것은 아마도 내가 필요로 추가해 나 실행합니다.json 파일을 파일의 경로 적절하지만,일을 내가 노력하지 않은 나를 위해 일했습니다. 감사

1

최고의 응답

0

그래,내가 해결 초기에 오류가 만에 직면하게 될 새로운 오류에 관한 다른 가져오는 문제는 이 시간이 실제로 내부에 코드,파일을 가져오는 수입할 때 프로그램을 실행하는 일반적으로.

Fix 구현하여 내 코드는 다음과 같습니다(내에서 실행됩니다.json)

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Flask",
            "type": "python",
            "request": "launch",
            "module": "flask",
            # Added new line cwd to specify initial working directory
            "cwd":"${workspaceRoot}",
            "env": {
                # Added ${workspaceRoot}/InterjectApi/"file name trying to run"}
                "FLASK_APP": "${workspaceRoot}/InterjectApi/server.py",
                "FLASK_ENV": "development"
            },
            "args": [
                "run",
                "--no-debugger"
            ],
            "jinja": true
        }
    ]
}
2021-11-23 18:16:30

다른 언어로

이 페이지는 다른 언어로되어 있습니다

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................