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
# -*- coding: utf-8 -*- | |
import re, requests, httplib, urllib, json | |
from flask import Flask, render_template, session, request, jsonify, current_app | |
from flask_wtf import Form | |
from wtforms import Field, StringField, SubmitField | |
from wtforms.validators import DataRequired, Regexp | |
from wtforms.widgets import TextInput, HTMLString |
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 ubuntu:14.04 | |
MAINTAINER Pan Jiabang, panjiabang@gmail.com | |
RUN \ | |
# use aliyun's mirror for better download speed | |
sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list && \ | |
apt-get update && \ | |
apt-get install -y nodejs curl git-core && \ | |
# use nodejs as node |
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
/* Abbreviate full ipv6 address | |
* By Brent Stees (http://facebook.com/brent.stees), 2014 | |
* MIT Licenced, see http://www.opensource.org/licenses/mit-license.php */ | |
function abbreviate_ipv6(ip){ | |
if(ip.indexOf("::") == -1) { | |
// needs to be abbreviated | |
// remove leading zeros |
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
# This is not used unless SQLALCHEMY_BINDS is not present | |
SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://{username}:{password}@{hostname}/{database}?charset=utf8' | |
SQLALCHEMY_BINDS = { | |
'master': 'mysql+pymysql://{username}:{password}@{hostname}/{database}?charset=utf8', | |
'slave': 'mysql+pymysql://{username}:{password}@{hostname}/{database}?charset=utf8' | |
} |
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
class with_request_context(object): | |
def __init__(self, f, app=None, request=None): | |
self.f = f | |
if app: | |
self.app = app | |
else: | |
self.app = www | |
if request: | |
self.request = request |
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
<VirtualHost *> | |
ServerName example.com | |
WSGIDaemonProcess www user=max group=max threads=5 | |
WSGIScriptAlias / /home/max/Projekte/flask-upload/flask-upload.wsgi | |
<Directory /home/max/Projekte/flask-upload> | |
WSGIProcessGroup www | |
WSGIApplicationGroup %{GLOBAL} | |
Order deny,allow |
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 collections import namedtuple | |
def convert(dictionary): | |
return namedtuple('GenericDict', dictionary.keys())(**dictionary) | |
""" | |
>>> d = dictionary(a=1, b='b', c=[3]) | |
>>> named = convert(d) | |
>>> named.a == d.a | |
True | |
>>> named.b == d.b |