Coder Social home page Coder Social logo

Comments (5)

defnull avatar defnull commented on July 30, 2024

Guessing a mimetype is actually very easy.
(copy&paste from Bottle send_file)

import mimetypes
def send_file(filename, ..., guessmime = True, mimetype = None):
    ....
    if guessmime and not mimetype:
        mimetype = mimetypes.guess_type(filename)[0]
    if not mimetype: mimetype = 'text/plain'
    ....

But be careful: The python mimetypes module is not completely thread save. It must be initialized in the main thread. # Python Issue #5853

from itty.

defunkt avatar defunkt commented on July 30, 2024

itty already includes guessing content_type: http://github.com/toastdriven/itty/blob/master/itty.py#L262-275

My patch merely calls that method for you in static_file.

from itty.

toastdriven avatar toastdriven commented on July 30, 2024

Again, the link doesn't seem to work for me. Help?

from itty.

defunkt avatar defunkt commented on July 30, 2024

Link should work now, sorry about that!

from itty.

toastdriven avatar toastdriven commented on July 30, 2024

Fixed in SHA: dde698a

from itty.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.