Não use UUID
como PK nas tabelas do seu banco de dados.
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
import json | |
import logging | |
from flask import Flask, g | |
from flask_oidc import OpenIDConnect | |
import requests | |
logging.basicConfig(level=logging.DEBUG) | |
app = Flask(__name__) |
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
RECAPTCHA_PUBLIC_KEY = '<public key>' | |
RECAPTCHA_PRIVATE_KEY = '<private key>' | |
def checkRecaptcha(response, secretkey): | |
url = 'https://www.google.com/recaptcha/api/siteverify?' | |
url = url + 'secret=' + str(secretkey) | |
url = url + '&response=' +str(response) |
@credit Yan Zhu (https://github.com/nina-zhu)
Flask is a microframework for Python based on Werkzeug, Jinja 2 and good intentions, it can help you get your Python application or website off the ground. Flask includes a simplified development server for testing your code locally, but for anything even slightly production related, a more secure and powerful web server is required.
In this guide, we will demonstrate how to install and configure some components on Ubuntu 14.04 to support and serve Flask applications. We will configure the uWSGI application container server to interface with our applications. We will then set up Nginx to reverse proxy to uWSGI, giving us access to its security and performance features to serve our apps.
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
brdocs = { | |
/** | |
* Enum com opções do validador | |
* @readonly | |
* @enum {number} | |
*/ | |
cpfcnpj: { "CPF": 1, "CNPJ": 2, "AMBOS": 3 }, | |
/** | |
* Função que valida CPF e CNPJ de uma só vez. |
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 module provides a simple WSGI profiler middleware for finding | |
bottlenecks in web application. It uses the profile or cProfile | |
module to do the profiling and writes the stats to the stream provided | |
To use, run `flask_profiler.py` instead of `app.py` | |
see: http://werkzeug.pocoo.org/docs/0.9/contrib/profiler/ | |
and: http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-xvi-debugging-testing-and-profiling | |
""" |
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 TEXT SEARCH CONFIGURATION fr ( COPY = french ); | |
ALTER TEXT SEARCH CONFIGURATION fr ALTER MAPPING | |
FOR hword, hword_part, word WITH unaccent, french_stem; | |
CREATE TEXT SEARCH CONFIGURATION en ( COPY = english ); | |
ALTER TEXT SEARCH CONFIGURATION en ALTER MAPPING | |
FOR hword, hword_part, word WITH unaccent, english_stem; | |
CREATE TEXT SEARCH CONFIGURATION de ( COPY = german ); | |
ALTER TEXT SEARCH CONFIGURATION de ALTER MAPPING |
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
package com.jelies.spring3tomcat7.config.quartz; | |
import org.quartz.spi.TriggerFiredBundle; | |
import org.springframework.beans.factory.config.AutowireCapableBeanFactory; | |
import org.springframework.context.ApplicationContext; | |
import org.springframework.context.ApplicationContextAware; | |
import org.springframework.scheduling.quartz.SpringBeanJobFactory; | |
/** | |
* This JobFactory autowires automatically the created quartz bean with spring @Autowired dependencies. |
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
Um método para otimizar as conexões com o banco de dados é estabelecer um pool de conexão, caso sua aplicação | |
não faça isto nativamente você pode usar alguma ferramenta como o pgbouncer [1]. | |
O principal motivo para manter um pool de conexões ativas com o banco de dados, é que o processo | |
de criar uma conexão com o banco de dados e posteriormente elimina-la gasta recursos e leva algum tempo, | |
o que pode ser pouco para uma conexão, mas para apps onde a conexão / desconexão ocorre com muita | |
frequência (como em aplicações web) manter um pool de conexões ativas, pode economizar algum tempo | |
entre cada solicitação. | |
Um pool de conexões trabalha de maneira muito simples, após a aplicação criar e usar a conexão com o |