Giter Site home page Giter Site logo

pallets / flask Goto Github PK

View Code? Open in Web Editor NEW
66.3K 2.1K 15.9K 10.28 MB

The Python micro framework for building web applications.

Home Page: https://flask.palletsprojects.com

License: BSD 3-Clause "New" or "Revised" License

Python 99.89% HTML 0.08% CSS 0.01% Shell 0.04%
python flask wsgi web-framework werkzeug jinja pallets

flask's People

Contributors

adambyrtek avatar dag avatar dasich avatar davidism avatar dawranliou avatar defuz avatar dependabot-preview[bot] avatar dependabot[bot] avatar florentx avatar flying-sheep avatar garenchan avatar greyli avatar jab avatar jeffwidman avatar kennethreitz avatar keyan avatar lepture avatar lord63 avatar mitsuhiko avatar pgjones avatar plaes avatar pre-commit-ci[bot] avatar rduplain avatar s3rvac avatar simonsapin avatar svenstaro avatar thiefmaster avatar thomaswaldmann avatar untitaker avatar wgwz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flask's Issues

Support for Flashing Categories

The new signature for flash() should look like this in 0.5:

def flash(message, category='message'):
    ...

The method to fetch messages then will also accept a parameter that allows pulling as tuples with the category as well:

def get_flashed_messages(with_categories=False):
    ...

If invoked with that parameter set to False (which is the default) just the strings are returned, otherwise tuples in the form (category, message).

Variable Module Prefix

The module branch support variable modules. Something like this:

wiki = Module(__name__, url_prefix='/<user>')

Then each function registered is passed 'user' as first parameter. This already works as far as I can see, however it would be better if that value can be attached to g instead. What should work (not tested) is this:

@wiki.before_request
def attach_user():
    g.wiki_user = request.view_args.pop('user', None)

The problem with this is that URLs generated still need that user attached, so url_for needs some kind of support for that. However I am not entirely sure how that should look like.

Long lived sessions staying long-lived after session.permanent set False

Fixed it by adding the session_expires=None to the end of this method call:

def save_session(self, session, response):
expires = None
if session.permanent:
expires = datetime.utcnow() + self.permanent_session_lifetime
session.save_cookie(response, self.session_cookie_name,
expires=expires, httponly=True, session_expires=None) <== only change

Per-module processors

There should be a @context_processor decorator for modules, so that a processor can be added on a per-module basis, in the same way as @before_request. A processor function defined this way would only be executed in the module space.

[from the mailinglist]

Bind test_request_context for interactive Python shell

For the interactive Python shell, the test_request_function should be invokable to bind the context to the end of the session for easier testing. Something like this:

>>> from yourapplication import app
>>> app.test_request_context().bind()
>>> from flask import request
>>> request.path
u'/'

Or something similar.

Python 3K

What would it take to get Flask up and running with Python 3? I heard you got Jinja2 up and running on py3k but I am less sure about Werkzeug and the WSGI spec in general for Python 3. Have you put any thought into it or had any luck trying to accomplish it?

Make it easier to add routes via add_url_rule

add_url_rule should accept an optional view function. Currently you need to do two steps to associate a rule, endpoint and view_function.

This issue is suggesting that it should only take one step. Replace add_url_rule(self, rule, endpoint, *_options) with add_url_rule(self, rule, endpoint, view_func=None, *_options)

Add easy way to set session expiry

It's quite difficult at the moment to set the expiry date for the session. Ideally something like this could work (although it might require subclassing SecureCookie):

if request.form.get('remember_me', False):
    session.expires = timedelta(days=30)

Set server_name in bind_to_environ()

_RequestContext binds the url_map without setting server_name, so it is impossible to make apps that serve dynamic subdomains. server_name should be an optional configuration.

environ = create_environ(path='/', base_url='http://www.test.com')
url_adapter = url_map.bind_to_environ(environ, server_name='test.com')
endpoint, kwargs = url_adapter.match('/')
assert endpoint == 'test'
assert 'subdomain' in kwargs
assert kwargs['subdomain'] == 'www'

environ = create_environ(path='/', base_url='http://foo.test.com')
url_adapter = url_map.bind_to_environ(environ, server_name='test.com')
endpoint, kwargs = url_adapter.match('/')
assert endpoint == 'test'
assert 'subdomain' in kwargs
assert kwargs['subdomain'] == 'foo'

GAE Support

Right now Flask does not support GAE, that should be fixed. Switch to FileSystemLoader and CWD usage if GAE is detected, stick to pkg_resources otherwise for better portability.

register_module fails when url_prefix not previously set

The following example (taken from the documentation, simplified) fails to work correctly.
The index() function is registered at / instead of /admin.

myapp/init.py:
from flask import Flask
from myapp.admin import admin
app = Flask(name)
app.register_module(admin, url_prefix='/admin')

myapp/admin.py
from flask import Module
admin = Module(name)
@admin.route('/')
def index():
return 'This should be at /admin'

Typo in flask quickstart docs

In section 'The Request Object' is a typo when doing route definition.
...
@app.route('/login', method=['POST', 'GET'])
def login():
...

the keyword argument should be 'methods' not 'method'.

Flash fails in nonobvious way when secret isn't set

Here's what fails http://paste.pocoo.org/show/202792/

The Flash section of the docs should at least mention that app.secret is required but I'm not sure that's enough.

One idea would be to require secret_key to be explicitly set and fail to run if it isn't.
For folks that don't need sessions they could pass a message to that effect to run().
My guess is session/flash will be used by more apps than not.

Make endpoint optional in @route

Make endpoint an option in the @route decorator. By default it would still use the function name. This would allow more flexibility in larger applications:

def route(self, rule, **options):
    def decorator(f):
        endpoint = options.pop('endpoint', f.__name__)
        self.add_url_rule(rule, endpoint, **options)
        return f
    return decorator

Inconsistent license language and attribution for snippets

Snippets are placed in the public domain when posted, but this is not reflected when snippets are viewed. Additionally, the whole display (code, comments, style and all) is currently reported as copyright Armin, with all rights implicitly reserved.

Documentation Modification (app.run)

Hi there,

I was reading through the documentation in the tutorial, and I think it may be beneficial to a lot of users (like myself) who develop on remote servers to include information about the optional host parameter in app.run():

app.run(host='your public ip')

It is listed on Application Setup Code at the bottom, but since the first page, 'Quickstart' demos an application, I think it should be included there (or at least linked).

Typo in flaskr tutorial -> testing

The sentence that reads

Now that you have finished the application and everything works as expected, it’s probably not the best idea to add automated tests to simplify modifications in the future.

Should probably read

Now that you have finished the application and everything works as expected, it’s probably a good idea to add automated tests to simplify modifications in the future.

Document setup.py

Documentation should show how a typical setup.py with distribute looks like and how it can be used to deploy code.

Implement dotted names for URL endpoints

It makes a lot of sense to change the way endpoints (the names of the functions / URL rules) are handled to also take the module name into account. Right now the function name is the URL name, but imagine you have a large applications consisting of multiple components. In that case, it makes a lot of sense to use dotted names for the URL endpoints.

add a way to add extra data for modus before dispatching to them

it would be nice if there was a way to generate extra data before dispatching to a module

something like this (bad example to get the idea across)

@app.route('//wiki', module=vcswiki)
def user_wiki(username):
    g.wiki = get_wiki_for_user(username)

@app.route('/help', module=vcswiki)
def help_wiki():
    g.wiki = get_help_wiki()

Access session object during unittest

Can we get the docs updated to include an example to access session object while unit testing.

Here is a potential solution, using unittest for flaskr

def test_session(self):
    with flaskr.app.test_request_context('/login', method='POST', data=dict(
                    username=flaskr.USERNAME, password=flaskr.PASSWORD,)):
        rv = flaskr.app.dispatch_request()
        assert flaskr.session['logged_in'] == True

    with flaskr.app.test_request_context('/login', method='POST', data=dict(
                    username=flaskr.USERNAME+'x', password=flaskr.PASSWORD+'x',)):
        rv = flaskr.app.dispatch_request()
        assert not flaskr.session.get('logged_in')

Get rid of the decorator function registering

Causes a lot of troubles for applications that have circular dependencies. It also requires that the whole application is imported when the system initializes or certain URLs will not be available right away.

Configuration Support

Apps should have some kind of config dict attached. That would make it a lot cleaner to deal with configuration values.

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.