要列出Flask项目所有视图对应的路径如何写?,flask视图,项目的视图函数都是用 @
要列出Flask项目所有视图对应的路径如何写?,flask视图,项目的视图函数都是用 @
项目的视图函数都是用 @app.route('...') 修饰访问路径的,有没有办法把所有的视图极其 GET, POST 之类的方法路径全列出来呢?
看文档:http://dormousehole.readthedocs.org/en/latest/api.html#application-object
可以用url_map来获取。
例如app = Flask(__name__),则是app.url_map就可以列出路径
项目路径
simplebbs
├── app
├── config.py
├── manage.py
├── requirements.txt
└── venv
在simplebbs路径下运行python命令
(venv) C:\zdata\code\simplebbs>pythonPython 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.160tel)] on win32Type "help", "copyright", "credits" or "license" for more informatio>>> import app>>> app.app.url_mapMap([<Rule '/topics/create' (GET, OPTIONS, HEAD, POST) -> topics.cre <Rule '/topics/latest' (GET, OPTIONS, HEAD) -> topics.latest>, <Rule '/users/setting' (GET, OPTIONS, HEAD, POST) -> users.setting> <Rule '/auth/signout' (GET, OPTIONS, HEAD) -> auth.signout>, <Rule '/auth/signin' (GET, OPTIONS, HEAD, POST) -> auth.signin>, <Rule '/auth/signup' (GET, OPTIONS, HEAD, POST) -> auth.signup>, <Rule '/auth/reset' (GET, OPTIONS, HEAD, POST) -> auth.reset>, <Rule '/auth/find' (GET, OPTIONS, HEAD, POST) -> auth.find>, <Rule '/topics/' (GET, OPTIONS, HEAD) -> topics.index>, <Rule '/' (GET, OPTIONS, HEAD) -> frontend.index>, <Rule '/topics/<id>/reply' (OPTIONS, POST) -> topics.reply>, <Rule '/topics/<id>' (GET, OPTIONS, HEAD) -> topics.topic>, <Rule '/static/<filename>' (GET, OPTIONS, HEAD) -> static>, <Rule '/users/<username>' (GET, OPTIONS, HEAD) -> users.index>])>>>
编橙之家文章,
相关内容
- json数据提取分配应用求思路,具体要求如正文,json正文
- 用python开源软件快速搭建数据分析平台,python开源软件
- Python变量scope正确理解含义是什么,pythonscope,globe = 10
- 新手请问Python函数参数值传递问题,python函数,现在有两
- 如何用python实现openSSL的PHP代码?,pythonopenssl,function ge
- 我的网站爬虫python代码为什么不能正常运行,哪里写错了
- Python2.7 GBK阿拉伯文字转换问题,,简单说,想问如何把
- Py模块rrdtool导入问题时报undefined symbol: rrd_flushcached?,
- python mysql Commands out of sync相关的问题,pythoncommands,py
- Python能做C/S.exe计算器程序吗?,pythons.exe,大家好,我是
评论关闭