推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
littlepython
V2EX  ›  Python

使用 flask 创建一个接口,别人上传文件,如何获取其中的文件

  •  
  •   littlepython · Apr 24, 2019 · 3823 views
    This topic created in 2713 days ago, the information mentioned may be changed or developed.
    别人一次会 post 多张图片 但是我只想取 pictype=1 的图片,flask 中如何获取这部分参数,或者有什么方法可以过滤掉 pictype=0 的部分


    Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
    Accept-Language: zh-cn
    Content-Type: multipart/form-data; boundary=---------------------------7daf10c20d06
    Accept-Encoding: gzip, deflate
    User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; CIBA; .NET CLR 2.0.50727)
    Host: 172.7.56.10
    Content-Length: 2740000
    Connection: close
    Cache-Control: no-cache

    -----------------------------7daf10c20d06
    Content-Disposition: form-data; name="userfile"; pictype=0&isurl=0&piclen=13000;filename="dev001_01_20110811155619_01_1.jpg"
    Content-Type: image/pjpeg

    <此处为图片数据或者 URL>
    -----------------------------7daf10c20d06
    Content-Disposition: form-data; name="userfile"; pictype=1&isurl=0&piclen=13000;filename="dev001_01_20110811155619_01_2.jpg"
    Content-Type: image/pjpeg

    <此处为图片数据或者 URL>
    2 replies  •  2019-04-24 17:08:30 +08:00
    vZexc0m
        1
    vZexc0m  
       Apr 24, 2019   ❤️ 1
    ```
    request.files.get("dffff").headers["Content-Disposition"]
    ```
    littlepython
        2
    littlepython  
    OP
       Apr 24, 2019
    @vZexc0m 谢谢
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2664 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 09:24 · PVG 17:24 · LAX 02:24 · JFK 05:24
    ♥ Do have faith in what you're doing.