Skip to content

Instantly share code, notes, and snippets.

@aster1sk
aster1sk / url_shortener.py
Last active April 21, 2022 03:58
Minimalistic URL shortener (Python/Flask/Mongo)
"""
Install : pip install pymongo flask
Minimalistic url shortener : use with curl -sd "url=http://example.com/" http://this-app.com/shorten
"""
from flask import Flask, request, redirect, abort
from pymongo import MongoClient
import base64, md5, re
con = MongoClient()
col = con.shortener.entries

Dockerfile

FROM lambci/lambda:build-python3.6

# Install python module needed for gdal and rasterio
RUN yum update -y && yum clean all
RUN yum install -y yum-plugin-ovl || true
RUN pip3 install cython numpy --no-binary numpy

# Install apt dependencies fro GDAL and drivers

RUN yum install -y libjpeg-devel zlib-devel libpng-devel libcurl-devel \