This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@app.route('/', methods=['GET', 'POST']) | |
def get_tiny_url(): | |
if request.method == 'POST' and request.is_json: | |
long_url = request.get_json().get('url') | |
if not long_url: | |
abort(400) | |
if not long_url.startswith('http'): | |
long_url = f'http://{long_url}' | |
h = blake2b(long_url.encode(), digest_size=20).hexdigest() | |
app.logger.debug(h) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@app.route('/<tiny_url>', methods=['GET']) | |
def get_long_url(tiny_url): | |
if request.method == 'GET': | |
try: | |
url_id = short_url.decode_url(tiny_url) | |
except Exception: | |
abort(500) | |
app.logger.debug(url_id) | |
url = Url.query.filter_by(id=url_id).first() | |
app.logger.debug(url) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE OR REPLACE FUNCTION pseudo_encrypt(VALUE bigint) returns bigint AS $$ | |
DECLARE | |
l1 bigint; | |
l2 bigint; | |
r1 bigint; | |
r2 bigint; | |
i int:=0; | |
BEGIN | |
l1:= (VALUE >> 32) & 4294967295::bigint; | |
r1:= VALUE & 4294967295; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from github import Github | |
import os | |
import sys | |
# First create a Github instance: using an access token | |
access_token = os.getenv('GITHUB_ACCESS_TOKEN') | |
g = Github(access_token) | |
# Select your repo |
OlderNewer