Coder Social home page Coder Social logo

mliermann / flask-common Goto Github PK

View Code? Open in Web Editor NEW

This project forked from schedutron/flask-common

0.0 1.0 0.0 22 KB

A Flask extension with lots of common time-savers (file-serving, favicons, etc).

License: Apache License 2.0

Python 100.00%

flask-common's Introduction

flask-common

A Flask extension with lots of common time-savers (file-serving, favicons, etc).

An example app:

import time
from flask import Flask
from flask_common import Common

app = Flask(__name__)
app.debug = True

common = Common(app)

@app.route("/")
@common.cache.cached(timeout=50)
def hello():
    time.sleep(1)
    return "Hello World!"


if __name__ == "__main__":
    common.serve()

Next:

  • Put a favicon.ico in your static folder.
  • Enjoy!

Nicities

HTTP Headers:

  • X-Powered-By: Flask.
  • X-Processed-Time: 0.000133037567139.

Other nice things:

  • @common.cache.cached(timeout=50) decorator for caching views in memory.
  • Favicon support (/favicon.ico redirects to /static/favicon.ico).

Web Server: Gunicorn + Meinheld

Automatically uses Gunicorn + Meinheld for production (when Flask.debug = False), Flask's dev server for development.

Configuration environment variables:

  • WEB_CONCURRENCY for specifying the number of synchronous gunicorn workers.
  • PORT for binding to a specific port.

File Server: WhiteNoise

Flask-Common automatically configures WhiteNoise to serve your static files.

Configurations

app.config['COMMON_FILESERVER_DISABLED'] = 1
app.config['COMMON_POWERED_BY_DISABLED'] = 1
app.config['COMMON_PROCESSED_TIME_DISABLED'] = 1

Cache configures

By default simple is a default cache type. But can you change this options, following below steps. Flask-Caching

app.config['COMMON_CACHE_TYPE'] = "simple"

flask-common's People

Contributors

kennethreitz avatar rochacbruno avatar riquellopes avatar nateprewitt avatar pplante avatar theelous3 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.