最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【记录】参考Flask教程去通过Flask-RESTful设计的Restful的API接口

Flask crifan 2779浏览 0评论

先是:

【记录】参考Flask教程去通过视图设计的Restful的API接口

再去参考:使用 Flask-RESTful 设计 RESTful API — Designing a RESTful API with Python and Flask 1.0 documentation

即:

Designing a RESTful API using Flask-RESTful – miguelgrinberg.com

和代码:

REST-tutorial/rest-server-v2.py at master · miguelgrinberg/REST-tutorial · GitHub

去试试。

先去安装Flask-RESTful

(RunningFast) ➜  RunningFast pip install flask-restful
Collecting flask-restful
  Downloading Flask_RESTful-0.3.5-py2.py3-none-any.whl
Collecting pytz (from flask-restful)
  Downloading pytz-2016.6.1-py2.py3-none-any.whl (481kB)
    100% |████████████████████████████████| 481kB 155kB/s 
Collecting six>=1.3.0 (from flask-restful)
  Using cached six-1.10.0-py2.py3-none-any.whl
Requirement already satisfied (use –upgrade to upgrade): Flask>=0.8 in /root/Envs/RunningFast/lib/python2.7/site-packages (from flask-restful)
Collecting aniso8601>=0.82 (from flask-restful)
  Downloading aniso8601-1.1.0.tar.gz (49kB)
    100% |████████████████████████████████| 51kB 85kB/s 
Requirement already satisfied (use –upgrade to upgrade): itsdangerous>=0.21 in /root/Envs/RunningFast/lib/python2.7/site-packages (from Flask>=0.8->flask-restful)
Requirement already satisfied (use –upgrade to upgrade): Jinja2>=2.4 in /root/Envs/RunningFast/lib/python2.7/site-packages (from Flask>=0.8->flask-restful)
Requirement already satisfied (use –upgrade to upgrade): Werkzeug>=0.7 in /root/Envs/RunningFast/lib/python2.7/site-packages (from Flask>=0.8->flask-restful)
Requirement already satisfied (use –upgrade to upgrade): click>=2.0 in /root/Envs/RunningFast/lib/python2.7/site-packages (from Flask>=0.8->flask-restful)
Collecting python-dateutil (from aniso8601>=0.82->flask-restful)
  Using cached python_dateutil-2.5.3-py2.py3-none-any.whl
Requirement already satisfied (use –upgrade to upgrade): MarkupSafe in /root/Envs/RunningFast/lib/python2.7/site-packages (from Jinja2>=2.4->Flask>=0.8->flask-restful)
Building wheels for collected packages: aniso8601
  Running setup.py bdist_wheel for aniso8601 … done
  Stored in directory: /root/.cache/pip/wheels/75/51/2e/c73ad8f76fd76e878c208a8e461a36fa6319282b2df7c7dea7
Successfully built aniso8601
Installing collected packages: pytz, six, python-dateutil, aniso8601, flask-restful
Successfully installed aniso8601-1.1.0 flask-restful-0.3.5 python-dateutil-2.5.3 pytz-2016.6.1 six-1.10.0

需要知道:

flask-restful add_resource endpoint

API Docs — Flask-RESTful 0.2.1 documentation

  • endpoint (str) – endpoint name (defaults to Resource.__name__.lower() Can be used to reference this route in fields.Url fields

然后需要去解决:

【已解决】supervisor去管理gunicorn的Flask后找不到debug输出的log信息

转载请注明:在路上 » 【记录】参考Flask教程去通过Flask-RESTful设计的Restful的API接口

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
82 queries in 0.236 seconds, using 22.14MB memory