Giter Site home page Giter Site logo

bernie-sits's Introduction

Bernie In Places

Deploy

An app that accidentally went viral! Read the story in WIRED here

Install

First, create a python virtual environment, and install all of the depenedencies.

python3 -m venv ve
source ve/bin/activate
pip install -r requirements.txt

Next, create a google cloud platform project with Street View Static API access (you will need a credit card to set this up)

https://console.cloud.google.com/apis/library/street-view-image-backend.googleapis.com

Set the following environment variables by adding the following lines to your .bash_profile, .zshrc, etc:

export API_URL='https://maps.googleapis.com/maps/api/streetview'
export KEY='YOUR-MAPS-STREETVIEW-KEY'
export SECRET='YOUR-GOOGLE-SECRET'

You might want to rename the variables to not conflict with existing ones.

Running

To run the web application locally

flask run

and, visit http://localhost:5000

For production deployment, I used gunicorn.

Since the site is down now, you can also use images.py as a command-line bernie meme creation tool with

python images.py 'FILENAME.jpg' 'LOCATION' 

If you plan on exceeding the rate limits or call cap, make sure to sign the url with -s or --sign (this also happens by default). If you're just doing this for fun, or want to look at a request url without the signature, you can use -n or --no-sign.

Procfile and Aptfile are required to deploy with Heroku

Contribute!

I'd like to make a self-sustaining version of this site that automatically tracks crowdfunding vs api/other site costs and pulls core functionality when funding dips below cost, bringing it back when funding returns. Check out the idea and contribute to the discussion!

Also join me in Discussions to discuss the future of the site. We'll be maintaining an aesthetically and functionally identical version of the original viral site, and another souped-up version with all the features requested. Backend optimizations like caching can go in the original version. Still trying to decide which version should be main

PRs and issues welcome!

Please don't deploy without permission! I'm working on figuring out the proper licensing and attributions for others to be able to deploy.

Licensing

This site is licensed under the GNU Affero General Public License

THANKS

This has been insane. 9,849,938 Bernie memes were created during the lifetime of this site!

bernie-sits's People

Contributors

dym-sh avatar jziesing avatar mrenoch avatar nicksawhney avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bernie-sits's Issues

Make image fusion in browser

Hey @nicksawhney ! Good job on making the Bernie meme a spash! My Fb timeline is swamped with funny Bernie memes.

I was trying to generate my own meme and realized that you pulled the original site due to API cost. I noticed that you are trying to handle the image fusion part in server. Actually this operation would be done in JavaScript in users' browser. As a result your entire site would be statically hosted on free places like Github itself.

Here's some packages to give you some rough ideas.

Thanks a lot for the fun generating work!

You can use CSS to overlay bernie

There's no need to do any computation server-side to overlay bernie, or use numpy/cv etc.

A CSS stylesheet can overlay the bernie.png image directly on top of a div that holds the result from google maps. I'll work on a PR on this in the evening if no one else gets to it.

Automate Crowdfunding and API Usage (KEEP THE SITE ALIVE!)

I just had an idea about how to keep the site going while keeping everything open source and community oriented. Let's automate the crowdfunding aspect. Monitor API calls and donations to crowdfunding, pull functionality when money runs out, bring it back when money returns. Duh! This is probably a bigger undertaking than most of the suggestions so far, but I am getting so many messages from people wanting to bring the site back. What if we used it to try a completely community supported site model, which doesn't even have to go through me.

If you're on board with this idea, let me know and let's discuss implementation details below. The hardest part will be figuring out how big a role third-parties play in the collection of funds.

Breakdown on API Costs

Hi,
Can you give a breakdown of the API cost from google. When I checked the pricing it seems that Streetview API would cost 5.6 dollars per 1000 requests [ $56K USD for 10 million requests]. Also, can you give a breakdown of how much you have got via public donations? Putting these numbers publically can probably help increase trust and further receive funds to help you breakeven in case donations didn't match the costs

Testing, logging, metrics!

I should've done this at the very beginning, but this site sorely needs testing, logging, and metrics. Feel free to submit any and all that you think are relevant! More updates to come in comments.

App fails to load in Heroku

I just attempted to simply deploy to Heroku from the Github page and faced the following issue right away.

I created my API key in APIs & Services, restricted the key to Street View Static API leaving application restrictions to None.
I grabbed my Street View Static API secret from: https://console.cloud.google.com/google/maps-apis/credentials

Jan 26 11:42:08 my-heroku-app heroku/web.1 Starting process with command `gunicorn --timeout=0 app:app`
Jan 26 11:42:12 my-heroku-app heroku/web.1 State changed from starting to up
Jan 26 11:42:13 my-heroku-app app/web.1 [2021-01-26 19:42:13 +0000] [9] [ERROR] Exception in worker process
Jan 26 11:42:13 my-heroku-app app/web.1 Traceback (most recent call last):
Jan 26 11:42:13 my-heroku-app app/web.1   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
Jan 26 11:42:13 my-heroku-app app/web.1     worker.init_process()
Jan 26 11:42:13 my-heroku-app app/web.1   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 119, in init_process
Jan 26 11:42:13 my-heroku-app app/web.1     self.load_wsgi()
Jan 26 11:42:13 my-heroku-app app/web.1   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 144, in load_wsgi
Jan 26 11:42:13 my-heroku-app app/web.1     self.wsgi = self.app.wsgi()
Jan 26 11:42:13 my-heroku-app app/web.1   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
Jan 26 11:42:13 my-heroku-app app/web.1     self.callable = self.load()
Jan 26 11:42:13 my-heroku-app app/web.1   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 49, in load
Jan 26 11:42:13 my-heroku-app app/web.1     return self.load_wsgiapp()
Jan 26 11:42:13 my-heroku-app app/web.1   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp
Jan 26 11:42:13 my-heroku-app app/web.1     return util.import_app(self.app_uri)
Jan 26 11:42:13 my-heroku-app app/web.1   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/util.py", line 358, in import_app
Jan 26 11:42:13 my-heroku-app app/web.1     mod = importlib.import_module(module)
Jan 26 11:42:13 my-heroku-app app/web.1   File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in import_module
Jan 26 11:42:13 my-heroku-app app/web.1     return _bootstrap._gcd_import(name[level:], package, level)
Jan 26 11:42:13 my-heroku-app app/web.1   File "<frozen importlib._bootstrap>", line 994, in _gcd_import
Jan 26 11:42:13 my-heroku-app app/web.1   File "<frozen importlib._bootstrap>", line 971, in _find_and_load
Jan 26 11:42:13 my-heroku-app app/web.1   File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
Jan 26 11:42:13 my-heroku-app app/web.1   File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
Jan 26 11:42:13 my-heroku-app app/web.1   File "<frozen importlib._bootstrap_external>", line 678, in exec_module
Jan 26 11:42:13 my-heroku-app app/web.1   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
Jan 26 11:42:13 my-heroku-app app/web.1   File "/app/app.py", line 3, in <module>
Jan 26 11:42:13 my-heroku-app app/web.1     import cv2
Jan 26 11:42:13 my-heroku-app app/web.1   File "/app/.heroku/python/lib/python3.6/site-packages/cv2/__init__.py", line 5, in <module>
Jan 26 11:42:13 my-heroku-app app/web.1     from .cv2 import *
Jan 26 11:42:13 my-heroku-app app/web.1 ImportError: libGL.so.1: cannot open shared object file: No such file or directory
Jan 26 11:42:13 my-heroku-app app/web.1 [2021-01-26 19:42:13 +0000] [9] [INFO] Worker exiting (pid: 9)
Jan 26 11:42:13 my-heroku-app app/web.1 [2021-01-26 19:42:13 +0000] [10] [ERROR] Exception in worker process
Jan 26 11:42:13 my-heroku-app app/web.1 Traceback (most recent call last):
Jan 26 11:42:13 my-heroku-app app/web.1   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
Jan 26 11:42:13 my-heroku-app app/web.1     worker.init_process()
Jan 26 11:42:13 my-heroku-app app/web.1   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 119, in init_process
Jan 26 11:42:13 my-heroku-app app/web.1     self.load_wsgi()
Jan 26 11:42:13 my-heroku-app app/web.1   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 144, in load_wsgi
Jan 26 11:42:13 my-heroku-app app/web.1     self.wsgi = self.app.wsgi()
Jan 26 11:42:13 my-heroku-app app/web.1   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
Jan 26 11:42:13 my-heroku-app app/web.1     self.callable = self.load()
Jan 26 11:42:13 my-heroku-app app/web.1   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 49, in load
Jan 26 11:42:13 my-heroku-app app/web.1     return self.load_wsgiapp()
Jan 26 11:42:13 my-heroku-app app/web.1   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp
Jan 26 11:42:13 my-heroku-app app/web.1     return util.import_app(self.app_uri)
Jan 26 11:42:13 my-heroku-app app/web.1   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/util.py", line 358, in import_app
Jan 26 11:42:13 my-heroku-app app/web.1     mod = importlib.import_module(module)
Jan 26 11:42:13 my-heroku-app app/web.1   File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in import_module
Jan 26 11:42:13 my-heroku-app app/web.1     return _bootstrap._gcd_import(name[level:], package, level)
Jan 26 11:42:13 my-heroku-app app/web.1   File "<frozen importlib._bootstrap>", line 994, in _gcd_import
Jan 26 11:42:13 my-heroku-app app/web.1   File "<frozen importlib._bootstrap>", line 971, in _find_and_load
Jan 26 11:42:13 my-heroku-app app/web.1   File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
Jan 26 11:42:13 my-heroku-app app/web.1   File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
Jan 26 11:42:13 my-heroku-app app/web.1   File "<frozen importlib._bootstrap_external>", line 678, in exec_module
Jan 26 11:42:13 my-heroku-app app/web.1   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
Jan 26 11:42:13 my-heroku-app app/web.1   File "/app/app.py", line 3, in <module>
Jan 26 11:42:13 my-heroku-app app/web.1     import cv2
Jan 26 11:42:13 my-heroku-app app/web.1   File "/app/.heroku/python/lib/python3.6/site-packages/cv2/__init__.py", line 5, in <module>
Jan 26 11:42:13 my-heroku-app app/web.1     from .cv2 import *
Jan 26 11:42:13 my-heroku-app app/web.1 ImportError: libGL.so.1: cannot open shared object file: No such file or directory
Jan 26 11:42:13 my-heroku-app app/web.1 [2021-01-26 19:42:13 +0000] [10] [INFO] Worker exiting (pid: 10)
Jan 26 11:42:14 my-heroku-app app/web.1 [2021-01-26 19:42:13 +0000] [4] [INFO] Shutting down: Master
Jan 26 11:42:14 my-heroku-app app/web.1 [2021-01-26 19:42:13 +0000] [4] [INFO] Reason: Worker failed to boot.

Licensing

I'm looking for some insight on how to license this thing. I'd like to be as open as possible with it, open source is awesome and I want others to be able to deploy this site if they want to. However, I have a few preferences (none of which are set in stone) that I'd like to use to guide which license to pick. If anyone has experience with this kind of thing, I'd love your insight!

  • I'd like credit for creating the original site if possible
  • I don't love the idea of others making a version of the site with ads and deploying it for themselves
  • I want to encourage open source contribution and creativity
  • I want to protect myself from an elasticsearch-type-situation

GitHub Discussions

Have you enabled Discussions on this repo? I have a few things that wouldn't be appropriate on issues. We could use this issue as a discussion if need be.

What's Next?

I'm thinking we maintain a relatively original-looking version of the site, and have another branch where we can go absolutely wild with everything people want to contribute -- styling, different images and overlays (like people have been asking for on twitter), changing image placement, all the rest! That version could become a more general open-source web based meme creation app. Would love anyone's thoughts!

(via @nicksawhney #8 (comment))

Keep the site up? I wonder if there's some free way of keeping this up to get to 10M memes

TypeError: 'NoneType' object is not subscriptable

$ flask run

  • Environment: production
    WARNING: This is a development server. Do not use it in a production deployment.
    Use a production WSGI server instead.
  • Debug mode: off
  • Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
    127.0.0.1 - - [25/Jan/2021 19:37:24] "GET / HTTP/1.1" 200 -
    127.0.0.1 - - [25/Jan/2021 19:37:25] "GET /favicon.ico HTTP/1.1" 404 -
    requesting from https://maps.googleapis.com/maps/api/streetview?location=new+york&size=640x640&key=
    403
    [2021-01-25 19:37:34,720] ERROR in app: Exception on / [POST]
    Traceback (most recent call last):
    File "/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
    File "/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
    File "/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
    File "/python3.8/site-packages/flask/_compat.py", line 39, in reraise
    raise value
    File "/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
    File "/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functionsrule.endpoint
    File "/home/aswin/Documents/bernie-sits/app.py", line 18, in login
    image = add_bernie(img_bytes)
    File "/home/aswin/Documents/bernie-sits/images.py", line 75, in add_bernie
    alpha_l * l_img[y1:y2, x1:x2, c])
    TypeError: 'NoneType' object is not subscriptable
    127.0.0.1 - - [25/Jan/2021 19:37:34] "POST / HTTP/1.1" 500 -

Caching

The biggest cost for this site was API requests. Caching will help offset this greatly. It would be nice to cache from some kind of unique image identifier instead of input string, since different inputs can cause the same image to be returned.

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.