GithubHelp home page GithubHelp logo

emmett-framework / emmett Goto Github PK

View Code? Open in Web Editor NEW
1.0K 32.0 70.0 3.77 MB

The web framework for inventors

License: Other

Python 98.37% CSS 0.93% HTML 0.54% JavaScript 0.16%
python web-framework asgi asyncio emmett

emmett's Introduction

Emmett

Emmett is a full-stack Python web framework designed with simplicity in mind.

The aim of Emmett is to be clearly understandable, easy to be learned and to be used, so you can focus completely on your product's features:

from emmett import App, request, response
from emmett.orm import Database, Model, Field
from emmett.tools import service, requires

class Task(Model):
    name = Field.string()
    is_completed = Field.bool(default=False)

app = App(__name__)
app.config.db.uri = "postgres://user:password@localhost/foo"
db = Database(app)
db.define_models(Task)
app.pipeline = [db.pipe]

def is_authenticated():
    return request.headers.get("api-key") == "foobar"
    
def not_authorized():
    response.status = 401
    return {'error': 'not authorized'}

@app.route(methods='get')
@requires(is_authenticated, otherwise=not_authorized)
@service.json
async def todo():
    page = request.query_params.page or 1
    tasks = Task.where(
        lambda t: t.is_completed == False
    ).select(paginate=(page, 20))
    return {'tasks': tasks}

pip version Tests Status

Documentation

The documentation is available at https://emmett.sh/docs. The sources are available under the docs folder.

Examples

The bloggy example described in the Tutorial is available under the examples folder.

Status of the project

Emmett is production ready and is compatible with Python 3.8 and above versions.

Emmett follows a semantic versioning for its releases, with a {major}.{minor}.{patch} scheme for versions numbers, where:

  • major versions might introduce breaking changes
  • minor versions usually introduce new features and might introduce deprecations
  • patch versions only introduce bug fixes

Deprecations are kept in place for at least 3 minor versions, and the drop is always communicated in the upgrade guide.

How can I help?

We would be very glad if you contributed to the project in one or all of these ways:

  • Talking about Emmett with friends and on the web
  • Adding issues and features requests here on GitHub
  • Participating in discussions about new features and issues here on GitHub
  • Improving the documentation
  • Forking the project and writing beautiful code

License

Emmett is released under the BSD License.

However, due to original license limitations, some components are included in Emmett under their original licenses. Please check the LICENSE file for more details.

emmett's People

Contributors

aidan-simard avatar bronte2k7 avatar cassiobotaro avatar dokenzy avatar erhuabushuo avatar gi0baro avatar giantcrocodile avatar hydeparkk avatar ianonavy avatar leon0824 avatar lethargilistic avatar marco-ponds avatar mijdavis2 avatar mtwtkman avatar nixtren avatar pixelindigo avatar ritece avatar rklabs avatar svenkeimpema avatar vanadium23 avatar veiko99 avatar waghanza 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

emmett's Issues

Caching for templating system

Actually templating system parse and exec templates code per request.
I would like to cache the source of the template and use python compile() in combination with exec.

Stream files from folders

Add a method to stream file directly from a folder.
The current stream_file() should be converted to stream_fromDB() or something like that.

Production Ready?

How far away is this project from being able to be run in the wild?

We need some tests

We really need tests.

  • DAL layer
  • Basic (app, global objects)
  • Routing
  • Sessions
  • Caching
  • Templating
  • AppModules
  • Extensions
  • Translator
  • Validations

Please create full examples

Hello, your sample code in docs do not work out of the box.
Its not clear that the full code should be written.
For example i´m trying to understand how to create a form

your docs says

form weppy import Field, Form
from weppy.validators import inSet

@app.expose('/form')
def a():
simple_form = Form({
'name': Field(),
'number': Field('int'),
'type': Field(
validation={'in': ['type1', 'type2']}
)
})
if simple_form.accepted:
#do something
return dict(form=simple_form)

but this is not enough to create a valid form code

i´m not sure but i thing i need to add
from weppy import App
app = App(name)

and
if name == "main":
app.run()

Please be more patient with dummies like me and most of the people that follows you.

Regards

Add `where` method to models and lambda conditions

Something like:

Event.where(lambda e: (e.start_at >= datetime(2015, 5, 20)) & (e.ends_at < datetime(2015, 6, 20)))

instead of

db((Event.start_at >= datetime(2015, 5, 20)) & (Event.ends_at < datetime(2015, 6, 20)))

Major error reloading Python

When I reloaded Python, I got this message on my screen:

uWSGI Error

Python application not found

And now I cannot access the Rascal anymore.
Can someone help please?

Allow to create "scopes" on Model sets

Just an idea. Something like:

class Event(Model):
    name = Field()
    start_at = Field('datetime')
    ends_at = Field('datetime')
    speaker = Field()

    @scope('active')
    def get_active(cls):
        return (cls.start_at <= request.now) & (cls.ends_at > request.now)

so we can query:

Event.active().where(Event.name.startswith('foo'))
# and/or
db(Event.speaker == "john").active()

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.