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.8.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.8-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: crud_mysql-0.1.8.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.8.tar.gz
Algorithm Hash digest
SHA256 3ed63fa43ff0488b8c479bb966f67caa336a9883fecd679efce12aeb3681106b
MD5 a9a6b839f575d1eed39c88bdbc294c87
BLAKE2b-256 1d1d405d2ba0decc3fc106d1acda9142ed2271b989b1902436bb6427a530f9b2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: crud_mysql-0.1.8-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.8-py3-none-any.whl
Algorithm Hash digest
SHA256 8056818379b2d061a9e80d1fe6916d1f23e38e357ec09288a16db5cac1e5a695
MD5 c74e9024674f1e52b2854397244b1019
BLAKE2b-256 ff0e9cafd70e2bb62fe422779c7ac70b79720b8ac948f89f6a823dbcf10448db

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