All Projects → lixxu → sanic-motor

lixxu / sanic-motor

Licence: other
simple motor wrapper for sanic

Programming Languages

python
139335 projects - #7 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to sanic-motor

axiol
🚀 An advanced Python Discord bot for everyone
Stars: ✭ 39 (-23.53%)
Mutual labels:  pymongo, motor
quart-motor
Motor support for Quart applications
Stars: ✭ 14 (-72.55%)
Mutual labels:  pymongo, motor
robot-mind-meld
A little game powered by word vectors
Stars: ✭ 31 (-39.22%)
Mutual labels:  sanic
buscaimoveis
Agregador de anúncios de imóveis a venda
Stars: ✭ 15 (-70.59%)
Mutual labels:  pymongo
sanic-restplus
Fully featured framework for fast, easy and documented API development with Sanic
Stars: ✭ 106 (+107.84%)
Mutual labels:  sanic
sanic-graphql-example
Sanic using Graphsql + SQLAlchemy example
Stars: ✭ 21 (-58.82%)
Mutual labels:  sanic
immuni-backend-common
Common repository for the app backend
Stars: ✭ 90 (+76.47%)
Mutual labels:  sanic
XATC
DIY CNC Automatic Toolchanger
Stars: ✭ 47 (-7.84%)
Mutual labels:  motor
sanic-sentry
Sentry integration to sanic web server
Stars: ✭ 31 (-39.22%)
Mutual labels:  sanic
Easy Driver
The EasyDriver is a simple to use stepper motor driver, compatible with anything that can output a digital 0 to 5V pulse (or 0 to 3.3V pulse if you solder SJ2 closed on the EasyDriver).
Stars: ✭ 27 (-47.06%)
Mutual labels:  motor
sanic compress
An extension which allows you to easily compress your Sanic responses with gzip.
Stars: ✭ 26 (-49.02%)
Mutual labels:  sanic
OLX Scraper
📻 An OLX Scraper using Scrapy + MongoDB. It Scrapes recent ads posted regarding requested product and dumps to NOSQL MONGODB.
Stars: ✭ 15 (-70.59%)
Mutual labels:  pymongo
FpOC
FPGA-based Field Oriented Control (FOC) for driving BLDC/PMSM motor.
Stars: ✭ 138 (+170.59%)
Mutual labels:  motor
microAuth
A fast, documented, and tested python3 API boilerplate
Stars: ✭ 24 (-52.94%)
Mutual labels:  sanic
postile
Project migrated to: https://gitlab.com/Oslandia/postile
Stars: ✭ 67 (+31.37%)
Mutual labels:  sanic
sanic-plugin-toolkit
Easily create Plugins for Sanic!
Stars: ✭ 49 (-3.92%)
Mutual labels:  sanic
Python-MongoDB-Example
A Live working Example Application of Python, Qt, PySide2, MongoDB, PyMongo, QTreeView, QAbstractTableModel
Stars: ✭ 41 (-19.61%)
Mutual labels:  pymongo
pyladies-courseware
Homework/task submit and review web app · based on React and Python aiohttp
Stars: ✭ 14 (-72.55%)
Mutual labels:  motor
ask-hadith
🔎 A Hadith search engine
Stars: ✭ 33 (-35.29%)
Mutual labels:  pymongo
simple-image-classifier
Simple image classifier microservice using tensorflow and sanic
Stars: ✭ 22 (-56.86%)
Mutual labels:  sanic

sanic-motor

Simple motor wrapper for Sanic.

Notice:
version 0.5 requires Sanic >= 21.3

Works on Sanic >= 0.4.0 and MOTOR_URI need to be defined in app.config

Installation

pip install sanic-motor

Usage

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from sanic import Sanic
from sanic.response import json
from sanic_jinja2 import SanicJinja2

from sanic_motor import BaseModel

app = Sanic(__name__)

settings = dict(
    MOTOR_URI='mongodb://localhost:27017/myapp', LOGO=None
)
app.config.update(settings)

BaseModel.init_app(app)
jinja = SanicJinja2(app, autoescape=True)


class User(BaseModel):
    __coll__ = 'users'
    __unique_fields__ = ['name']
    # __unique_fields__ = ['name, age']   # name and age for unique


@app.route('/')
async def index(request):
    cur = await User.find(sort='name')
    return jinja.render('index.html', request, users=cur.objects)


@app.route("/show/<id>")
async def show(request, id):
    # add as_raw = True to get the dict format record
    user_dict = await User.find_one(id, as_raw=True)

    # user = await User.find_one(id)
    return json(dict(user=user_dict))


if __name__ == '__main__':
    app.run(host='127.0.0.1', port=8000, debug=True)

see examples and source code for details.

Run example:

$cd example
$virtualenv venv
$. venv/bin/activate
$pip install -r requirements.txt
$python myapp.py

Open http://localhost:8000 to see the example page.

example

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].