GithubHelp home page GithubHelp logo

zankoku-okuno / flask-verbs Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 0.0 168 KB

DEPRECATED: I am removing this project in the near future

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

Python 100.00%

flask-verbs's Introduction

Flask-Verbs

Nice syntax to help Flask work with HTTP verbs, an important part of a RESTful breakfest.

We're licensed the same as Flask (BSD 3-clause), so no worries.

After installing the extension (Verbs(app)), your application will get a new method .verbs which works very similarly to the normal .route method, but it will instead decorate a whole class. All-caps methods on a .verbs-decorated class will be used to respond to requests of the corresponding HTTP method.

@app.verbs('/login')
class Login:
    def __init__(self):
        self.form = LoginForm()

    def GET(self):
        return render_template('login.html', form=self.form)

    def POST(self):
        if self.form.validate():
            # authenticate
            return redirect(url_for('index'))
        else:
            return self.GET()

If the class has a .pre method, it will be called before dealing with the HTTP method. If pre returns anything other than None, then that value will be used as the return value from the view, and the HTTP method will be skipped.

This extension should play nice with others. In particular, you should be able to use decorators on .verbs-enabled classes and on their methods. If you experience problems or have questions, submit a bug report.

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.