Skip to content

Commit

Permalink
Revert "Add flask dynamic configurations"
Browse files Browse the repository at this point in the history
This reverts commit 67878cb.
  • Loading branch information
paulacamargo25 committed Jul 22, 2022
1 parent 67878cb commit 9883896
Showing 1 changed file with 0 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,40 +44,6 @@ export class DynamicPythonDebugConfigurationService implements IDynamicDebugConf
justMyCode: true,
});
}

const flaskPath = await this.getFlaskPath(folder);

if (flaskPath) {
providers.push({
name: 'Dynamic Python: Flask',
type: DebuggerTypeName,
request: 'launch',
module: 'flask',
env: {
FLASK_APP: path.relative(folder.uri.fsPath, flaskPath),
FLASK_ENV: 'development',
},
args: ['run', '--no-debugger'],
jinja: true,
justMyCode: true,
});
}

return providers;
}

private async getFlaskPath(folder: WorkspaceFolder) {
const initPaths = await this.fs.search(path.join(folder.uri.fsPath, '**/__init__.py'));
const appPaths = await this.fs.search(path.join(folder.uri.fsPath, '**/app.py'));
const wsgiPaths = await this.fs.search(path.join(folder.uri.fsPath, '**/wsgi.py'));
const possiblePaths = [...initPaths, ...appPaths, ...wsgiPaths];

const regExpression = /app(?:lication)?\s*=\s*(?:flask\.)?Flask\(|def\s+(?:create|make)_app\(/;

const flaskPaths = possiblePaths.filter((applicationPath) =>
regExpression.exec(this.fs.readFileSync(applicationPath).toString()),
);

return flaskPaths.length ? flaskPaths[0] : null;
}
}

0 comments on commit 9883896

Please sign in to comment.