[英]How to debug a flask route with pycharm
I'm looking at https://github.com/ibininja/upload_file_python . 我在看https://github.com/ibininja/upload_file_python 。 I'm working in win 7 with pycharm 2017. The main code contains:
我正在使用pycharm 2017在win 7中工作。主要代码包含:
@app.route("/upload", methods=["POST"])
def upload():
folder_name = request.form['superhero']
'''
# this is to verify that folder to upload to exists.
if os.path.isdir(os.path.join(APP_ROOT, 'files/{}'.format(folder_name))):
print("folder exist")
'''
target = os.path.join(APP_ROOT, 'files/{}'.format(folder_name))
print(target)
I'd like to debug this in pycharm. 我想在pycharm中调试它。 I can debug the '/' route as in the screenshot.
我可以如屏幕截图所示调试“ /”路由。 How do I debug a specific flask route like "/upload" ?
如何调试特定的烧瓶路径,例如“ / upload”?
You can place a break point at folder_name = request.form['superhero']. 您可以在folder_name = request.form ['superhero']处放置一个断点。 Run your whole project in debug mode and when you request the endpoint through postman(its a tool for testing endpoints) you can see your code will stop at that break point.
在调试模式下运行整个项目,当您通过postman(用于测试端点的工具)请求端点时,您会看到代码将在该断点处停止。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.