Example #1
0
# logger setup
logger = logging.getLogger("simplepypicache")
logger_format = logging.Formatter(
    "%(asctime)-15s %(levelname)s %(message)s")
handler = logging.StreamHandler(sys.stdout)
handler.setFormatter(logger_format)
logger.addHandler(handler)
logger.setLevel(logging.getLevelName(
    os.environ.get("SCPYPI_LOG_LEVEL", "DEBUG")))

scraper = SimpleScrapingLocator(PYPI_INDEX)
app = Flask(__name__)
app.config["DEBUG"] = True
app.config["CACHE_TYPE"] = os.environ.get("CACHE_TYPE", "simple")
app.config["CACHE_KEY_PREFIX"] = os.environ.get(
    "CACHE_KEY_PREFIX", "scpypi_")

if app.config["CACHE_TYPE"] == "redis":
    assert "CACHE_REDIS_URL" in os.environ
    app.config["CACHE_REDIS_URL"] = os.environ["CACHE_REDIS_URL"]

cache = Cache(app)


@app.route("/simple/")
@cache.memoize(300)
def index():
    data = list(scraper.get_distribution_names())
    data.sort()
    return render_template("simple.html", package_names=data)
Example #2
0
app = Flask(__name__)

# configuration
app.config["DEBUG"] = True
app.config["VALID_SOLAR_SYSTEMS"] = {
    "-1": "Universe",
    "30000142": "Jita",
    "30002187": "Amarr",
    "30002659": "Dodixie",
    "30002510": "Rens",
    "30002053": "Hek",
}
app.config["USER_AGENT"] = "Evepraisal/1.0 +http://evepraisal.com/"
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:////%s/data/scans.db" % os.getcwd()
app.config["CACHE_TYPE"] = "memcached"
app.config["CACHE_KEY_PREFIX"] = "evepraisal"
app.config["CACHE_MEMCACHED_SERVERS"] = ["127.0.0.1:11211"]
app.config["CACHE_DEFAULT_TIMEOUT"] = 10 * 60
app.config["TEMPLATE"] = "sudorandom"
app.config["SECRET_KEY"] = "SET ME TO SOMETHING SECRET IN THE APP CONFIG!"
app.config["USER_DEFAULT_OPTIONS"] = {"autosubmit": False, "share": True}

app.config.from_pyfile("../application.cfg", silent=True)

locale.setlocale(locale.LC_ALL, "")

oid = OpenID(app)
db = SQLAlchemy(app)
babel = Babel(app)
cache = Cache()
cache.init_app(app)