Are you geek enough to save images on the web to your cloud storage account before sharing on Twitter? Cool, I made something for you. You will install a web server, get a cloud storage from Azure or AWS S3 and then grab a Chrome extension to generate permanent links on the web that could last 20 years!
This is the web server part of for Permalinker, a Python web application exposing an API to upload links. Uses Flask web microframework.
This app is ready to deploy on Heroku, however, you can run this anywhere you'd like if you have your own hosting space.
Supported datastores at the moment:
(hackers, feel free to provide implementations for other cloud storages!)
Sign up for a free Heroku account and get Heroku Toolbelt on your machine.
Open a terminal window and navigate to permalink/
folder you checked out
from Github in the previous step. Create application:
$ heroku apps:create
Creating vast-atoll-8883... done, stack is cedar
http://vast-atoll-8883.herokuapp.com/ | git@heroku.com:vast-atoll-8883.git
Your application URL will be the one above. Push the application package to Heroku:
git push heroku master
If the command succeeds with a message like the following your app is now deployed to Heroku at specified URL:
...
-----> Compressing... done, 31.5MB
-----> Launching... done, v3
http://vast-atoll-8883.herokuapp.com/ deployed to Heroku
If you navigate to the URL you got, you will probably get an application error. This is because you have not set environment variables for Heroku application. Here's how to set environment variables for a configuration using Azure Storage:
heroku config:set STORAGE=azure
heroku config:set AZURE_CONTAINER=testcontainer
heroku config:set AZURE_ACCOUNT_NAME=ahmet
heroku config:set AZURE_ACCOUNT_KEY=00000000000000000000000000
Try navigating to URL again, if you are not seeing "Application Error", you
are good! Otherwise run heroku logs -t
to see logs and troubleshoot.
Anyone with a link to your permalinker server can use it to fill up your storage account and mess with your monthly cloud service bill.
To prevent that, you can set an username/password in the following environment variables for your server:
heroku config:set PERM_USER=your-username
heroku config:set PERM_USER=your-password
It it optional to use this, but it's highly recommended. You need to use the same credentials on the browser extension to authenticate.
Make sure you have a Windows Azure account. Read this tutorial on How to create storage account on Windows Azure
At the end, click "Manage Keys" for your subscription. Using the account name and one of account keys, configure your heroku service as follows
heroku config:set STORAGE=azure
heroku config:set AZURE_CONTAINER=give-a-container-name
heroku config:set AZURE_ACCOUNT_NAME=your-account
heroku config:set AZURE_ACCOUNT_KEY=your-storage-account-key
Please note:
Make sure you have a Amazon Web Services account. Read this tutorial on Getting your Acccess ID and Secret Access Key.
Configure your heroku service as follows
heroku config:set STORAGE=s3
heroku config:set AWS_ACCESS_KEY_ID=your-access-key-id
heroku config:set AWS_SECRET_ACCESS_KEY=your-secret-access-key
heroku config:set AWS_S3_BUCKET=pick-a-bucket-name
Please note:
alp-perma
).After setting up the service, install the Google Chrome extension.
Go to Options of the extension, put the API base URL as http://{{your-hostname}}/api/1
. For example if yours is "flying-duck-1234.herokupp.com", put down http://flying-duck-1234.herokuapp.com/api/1
.
Hit "Save & Close". Browse the web. Find an image. Right click. Hit Permalink on cloud!, profit!
(I highly recommend doing this on Linux or Mac OS X environment.)
Make sure you have pip
installed on your machine (sudo easy_install pip
).
I recommend using virtualenvwrapper
to keep dependencies organized
mkvirtualenv permalinker
git clone git@github.com:ahmetalpbalkan/permalinker.git
cd permalinker
workon permalinker
Install dependencies:
pip install -r requirements.txt
Set environment variables (example is for Azure Storage, see S3 samples above)
export STORAGE=azure
export AZURE_CONTAINER=testcontainer
export AZURE_ACCOUNT_NAME=ahmet
export AZURE_ACCOUNT_KEY=00000000000000000000000000
Start the web application
$ python runserver.py
* Running on http://0.0.0.0:5000/
Navigate to URL shown above.