• 第25月第17天 django rest framwork authentication /tmp/mysql.sock


    1.authentication

    https://www.django-rest-framework.org/api-guide/authentication/#authentication

     2.django-rest-framework-jwt

    curl -X POST -H "Content-Type: application/json" -d '{"username":"admin","password":"password123"}' http://localhost:8000/api-token-auth/

    http://getblimp.github.io/django-rest-framework-jwt/#installation

    3.djoser

        'rest_framework',
        'rest_framework.authtoken',
        'djoser',

    You need to add 'rest_framework.authtoken' to your INSTALLED_APPS
    curl -X POST http://127.0.0.1:8088/auth/token/login/ --data 'username=djoser&password=djoser'

     curl -X POST http://127.0.0.1:8000/api/v1/auth/token/login/ -H "Content-Type: application/json" --data '{"username":"aa123456","password":"aa123456"}'

     

    curl -X POST http://localhost:8000/api/v1/owner/object/all -H "Content-Type: application/json" -H 'Authorization: Token 'baa10f5da4f6e775fd50ca412be4bd828bd5c0d4  --data '{"username":"aa123456","password":"aa123456"}'

     

     

    https://djoser.readthedocs.io/en/stable/sample_usage.html

    pip install httpie

    http GET http://localhost:8000/api/v1/article Authorization:" Token baa10f5da4f6e775fd50ca412be4bd828bd5c0d4"

     

    echo '{"author":"aa123456","title":"11114","content":"11114"}' | http POST http://localhost:8000/api/v1/article/add Authorization:" Token baa10f5da4f6e775fd50ca412be4bd828bd5c0d4"

     

     

     

    上传文件

    http -f POST http://localhost:8000/uploadfiles/ Authorization:" JWT eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjozLCJ1c2VybmFtZSI6IjE4MTExMTExMTEyIiwiZXhwIjoxNTQwNTE1NjA5LCJlbWFpbCI6bnVsbH0.LGcL0NUF1EzJkdLApio15eTGQ6GuYYYl4qekZMoVrcI" file@../aa.png

     

     

    https://httpie.org/doc#non-string-json-fields

     

    4.获取用户post json数据

            data=JSONParser().parse(request)
            print (data["username"])
    

      

    https://blog.csdn.net/Oudelosiki/article/details/79827920

    5.xampp mysql

    ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock'

     

    ln -s /Applications/XAMPP/xamppfiles/var/mysql/mysql.sock /tmp/mysql.sock

     

     

    6.上传文件重命名

     

    https://www.cnblogs.com/zhaoyingjie/p/6894979.html

     

     

  • 相关阅读:
    【java】一种自动生成数据库文档的方法
    sublime vintage mode 按住一个键(比如 j)不会重复的问题
    SQL Service服务更换帐户后无法启动的情况(Security 4625 Type 5)
    隐藏的计划任务运行,导致账户被锁的调查方法
    nodejs 热更新页面
    数组转tree arrToTree
    compose函数
    react 类组件的生命周期
    qiankun 微应用demo
    application 'xxx' died in status LOADING_SOURCE_CODE: [qiankun] You need to export lifecycle functions in xxx entry
  • 原文地址:https://www.cnblogs.com/javastart/p/9801754.html
Copyright © 2020-2023  润新知