Some Flask custom extension
Project description
Flask XinIDEA
Some Flask custom extension
- redprint
- reflectdb
Install
pip install --index-url https://test.pypi.org/simple/ --no-deps -U flask-xinidea
Redprint
- Usage
from flask import Flask
from flask import Blueprint
from flask_xinidea.redprint import Redprint
app = Flask(__name__)
bp = Blueprint('test', __name__)
test = Redprint(bp, url_prefix='/test')
@test.route('')
def index():
return 'this is a test'
app.register_blueprint(bp)
if __name__ == "__main__":
app.run()
- Test
flask run
flask routes
curl http://127.0.0.1:5000/test
ReflectDB
- Usage
from flask import Flask
from flask import Blueprint
from flask_xinidea.redprint import Redprint
from flask_xinidea.reflectdb import ReflectDB
settings = dict(
SQLALCHEMY_TRACK_MODIFICATIONS=False,
SQLALCHEMY_DATABASE_URI='mysql+cymysql://localhost/temp',
SQLALCHEMY_BINDS={
'test': 'mysql+cymysql://localhost/test'
}
)
app = Flask(__name__)
app.config.from_mapping(settings)
bp = Blueprint('test', __name__)
test = Redprint(bp, url_prefix='/test')
# the test is the SQLALCHEMY_BINDS key or
# a SQLALCHEMY_DATABASE_URI like 'mysql://localhost/temp'
testdb = ReflectDB('test', app)
# testdb = ReflectDB('mysql://localhost/temp')
User = testdb.get_table('users')
@test.route('')
def index():
return 'this is a test'
@test.route('/users/<int:id>')
def get_user(id):
user = User.query.get(id)
if user:
return user.name
else:
return 'Not exists'
app.register_blueprint(bp)
if __name__ == "__main__":
app.run()
- Test
flask routes
flask run
curl http://127.0.0.1:5000/test/users/user:id
2019-11-29 by phiix
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
flask-xinidea-0.0.4.tar.gz
(2.2 kB
view details)
Built Distribution
File details
Details for the file flask-xinidea-0.0.4.tar.gz
.
File metadata
- Download URL: flask-xinidea-0.0.4.tar.gz
- Upload date:
- Size: 2.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.7.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
4f407446dbf9ea0cc4c4780bf44fb026ca1d5a30a2a1dd6ac5f4a587ce64afae
|
|
MD5 |
0ab1bb5c9d115e5cb4c974efa6211e07
|
|
BLAKE2b-256 |
b6bbce6c3ee214a31d4e6ab00bd29c32a3a5d5fa89a7675bf0c456771e41729f
|
File details
Details for the file flask_xinidea-0.0.4-py3-none-any.whl
.
File metadata
- Download URL: flask_xinidea-0.0.4-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.7.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
797154d5573a60a72f10f1de09c1dd5f91473fbad83238822f8e4a7cb2999828
|
|
MD5 |
cfa27568068e7e684a29f29101cc687a
|
|
BLAKE2b-256 |
8960a935cbc19578e263439b1bec7ddd5ba858a0d32981b03c91e6819587a1bd
|