Git Product home page Git Product logo

Comments (11)

kura avatar kura commented on August 30, 2024

I would suggest it has something to do with it not being a valid image extension. Edit your URLs so you always end in something like /badge.png like the badges for pypipins do.

from pypipins.

karan avatar karan commented on August 30, 2024

Ah yeah I will try.

from pypipins.

karan avatar karan commented on August 30, 2024

@kura

Now the problem is in the route. Because I want the URL in route, flask won't be able to tell if the format is part of the URL or not.

Example:

http://sopins.herokuapp.com/twitter/png/https://www.google.com

to

http://sopins.herokuapp.com/twitter/https://www.google.com.png

Any way to get around that?

from pypipins.

kura avatar kura commented on August 30, 2024

Your URL scheme is totally messed up. Try using this, for example.

@app.route('/facebook/<fb_type>/<path:url>/pin.<format>', methods=['GET'])

@app.route('/<generator>/<path:url>/pin.<format>', methods=['GET'])

In your URL formatting you had format in the wrong place, you can't change the routing the way you were trying to do it without changing where the arguments are set in the scheme.

The reason you have to return some kind of MIME type at the end of the image URL is because not all browsers, caching systems etc will cache the result (like GitHubs caching layer) based on the Content-Type MIME without the image having a valid MIME extension.

from pypipins.

karan avatar karan commented on August 30, 2024

That makes sense. But this still doesn't seem to work for some reason (karan/sopins@2da6ff2).

http://sopins.herokuapp.com/twitter/https://www.google.com/pin.png

from pypipins.

kura avatar kura commented on August 30, 2024

I cloned your repository and tested those lines myself before I wrote my response, so they really do work. I'll do a pull request of my changes for you.

from pypipins.

kura avatar kura commented on August 30, 2024

Pull request done. As a note, your code was looking for badge.<extension> but were trying to access pin.<extension>

from pypipins.

karan avatar karan commented on August 30, 2024

I'm not sure what you are referring to, but in my latest commit, on this line https://github.com/karan/sopins/blob/2da6ff2126a932477e5ce9caa027f020c7014302/pins.py#L95 I look for pin.<format>. then in my README, I refer the same URL, but the CDN fails to get the image.

I tried your PR too, but it doesn't seem to work on Github.

from pypipins.

kura avatar kura commented on August 30, 2024

You're returning an invalid content-type header.

GET /twitter/https://kura.io/pin.png HTTP/1.1                        
Host: sopins.herokuapp.com

HTTP/1.1 200 OK
Content-Type: png
Date: Sat, 07 Jun 2014 20:00:43 GMT
Server: gunicorn/18.0
Content-Length: 1149
Connection: keep-alive

from pypipins.

karan avatar karan commented on August 30, 2024

Oh crap. Well that fixed it. Thanks

from pypipins.

kura avatar kura commented on August 30, 2024

Any time.

from pypipins.

Related Issues (20)

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.