Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions dap-python.el
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,22 @@ strings, for the sake of launch.json feature parity."
;; them to unspecified instead. Some templates in this file set such
;; properties (e.g. :module) to nil instead of leaving them undefined. To
;; support them, sanitize CONF before passing it on.
(when program
(if module
(push program python-args)
(plist-put conf :program program)))
(if (string-equal module "flask")
;; For flask module we need to strip filename from launch parameters
;; parameters are mostly ("<pathToFile/file.py", "parameters")
;; but when you launch flask, you should only launch run in the directory
;; with flask app
;; So in the next code we search for run in the array and everything before
;; will be deleted. Else run original code
(catch 'found
(dolist (p python-args)
(when (equal p "run")
(throw 'found p))
(cdr python-args)))
(when program
(if module
(push program python-args)
(plist-put conf :program program))))

(cl-remf conf :args)
(plist-put conf :args (or python-args []))
Expand Down
27 changes: 27 additions & 0 deletions docs/page/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,33 @@ settings.
:request "launch"
:name "My App"))
```
2.1 Flask app

Default template from vscode can be used to launch flask app. Please create file **launch.json** in **.vscode** subfolder of project's root folder. And the contents can look like this example.
```
{
"version": "0.2.0",
"configurations": [
{
"name": "<ProjectName>",
"type": "python",
"request": "launch",
"module": "flask",
"env": {
"FLASK_APP": "<location of app.py file>",
"FLASK_DEBUG": "1"
},
"args": [
"run",
"--no-debugger",
"--no-reload"
],
"jinja": true,
"justMyCode": true
}
]
}
```

3. Template parameters

Expand Down