Skip to main content

crud defiend by json

Project description

main.py / app.py - example

from flask import Flask from flask_cors import CORS from crud_mysql import crud

app = Flask(name)

app.register_blueprint(crud)

if name == "main": app.run(host="0.0.0.0", debug=True)

cred.json - example

{ "user": { "allowd_methods": ["GET", "POST", "DELETE", "PUT"], "fetch_all": "true", "schema": { "name": "VARCHAR(100)", "email": "VARCHAR(100)", "encrypted_password": "VARCHAR(100)", "account_id": "INT", "is_active": "INT" } }, "account": { "allowd_methods": ["GET", "POST", "DELETE"], "fetch_all": "false", "schema": { "name": "VARCHAR(100)", "subscription_type": "VARCHAR(100)", "root_user": "INT" } } }

using tokens:

to protect endpoints by verifying tokens - add protected_methods to that object for example:

{ "car": { "allowd_methods": ["GET", "POST", "DELETE", "PUT"], "protected_methods": ["GET"], "fetch_all": "true", "schema": { "owner": "VARCHAR(100)", "color": "VARCHAR(100)", "licence_plate": "INT" } } }

here when using "GET" to get a car we will need to add a token.

important: also add to app.py the line: set_jwt_protection(app)

in order for this to work a few things need to be set: an environment varriable JWT_ALGORITHM should be set. the options are:

  • RS256
  • HS256 if none are set it will default to HS256.

if the algorithim being used is HS256 then a variable needs to be set for SECRET_KEY. this has to be the same SECRET_KEY that was used for creating the jwt.

if the algorithim being used is RS256. a variable needs to be set for SECRET_KEYS_PATH. and at that path there needs to be a public.pem it has to be the same cert that was used to create the jwt.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

crud_mysql-0.1.9.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

crud_mysql-0.1.9-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file crud_mysql-0.1.9.tar.gz.

File metadata

  • Download URL: crud_mysql-0.1.9.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for crud_mysql-0.1.9.tar.gz
Algorithm Hash digest
SHA256 766c95d6218dda4fc562be17907c8ca1f8760f24015fc6ec093365ab287f44a4
MD5 b2e15bb3575fb0c0ca18927fb9fd8733
BLAKE2b-256 9482744b37a079307ad647561c7ce02fcf63a7573d53984368ec0d21ee41cdbf

See more details on using hashes here.

File details

Details for the file crud_mysql-0.1.9-py3-none-any.whl.

File metadata

  • Download URL: crud_mysql-0.1.9-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for crud_mysql-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 067591d8d704bb5e57fda3ea111697f150968cbb68f6ce47730064d979ca5197
MD5 4f9e108ed99e9f67e482eb6082229368
BLAKE2b-256 0e4136755788838dbd88a45d2bc80e594253dfe44cff6f469536206b3ad19830

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page