API¶
The technical part of the documentation that covers what certain interfaces do within EverNode.
Classes¶
This part of the documentation covers all the classes of EverNode.
App¶
-
class
evernode.classes.
App
(name, prefix=None, middleware=None, root_path=None, config_path=None)¶ Creates a Custom Flask App
-
prefix
¶ Makes every URL require ending prefix. eg. prefix=”v1”, https://example.com/v1/
-
middleware
¶ Set before middleware for all routes(environ, wsgi app)
-
root_path
¶ Set a root path with an absolute system folder path
-
config_path
¶ Set a config path(config.json) with an absolute system folder path
-
app
¶ alias of
flask.app.Flask
-
get_modules
() → list¶ Get the module names(folders) in root modules folder
-
load_before_middleware
(before_middleware)¶ Set before app middleware
-
load_config
()¶ Load EverNode config.json
-
load_cors
()¶ Default cors allow all
-
load_database
()¶ Load default database, init flask-SQLAlchemy
-
load_language_files
()¶ Load language fiels in resources/lang dirs
-
load_modules
()¶ Load folders(custom modules) in modules folder
-
BaseResponse¶
-
class
evernode.classes.
BaseResponse
(status_code, message=None, data=None, environ=None)¶ Base class for a HTTP response
-
content
() → str¶ Get full content of response
-
data
(data=None)¶ Set response data
-
message
(message=None)¶ Set response message
-
mimetype
() → str¶ Return private minetype
-
quick_response
(status_code)¶ Quickly construct response using a status code
-
response
¶ alias of
flask.wrappers.Response
-
response_model
¶ alias of
evernode.models.response_model.ResponseModel
-
status
(status_code=None)¶ Set status or Get Status
-
Cron¶
-
class
evernode.classes.
Cron
¶ - All you need to do is init Cron class:
- cron = Cron()
- Then add tasks to schedule
- cron.schedule.every(1).seconds.do(test_job)
-
running
()¶ Display running time and if Cron was enabled
-
schedule
= <module 'schedule' from '/home/docs/checkouts/readthedocs.org/user_builds/evernode/envs/latest/lib/python3.7/site-packages/schedule/__init__.py'>¶
Email¶
-
class
evernode.classes.
Email
(send_as_one=False)¶ Set up an email
-
add_address
(address)¶ Add email address
-
add_addresses
(addresses)¶ Add addresses from array
-
add_cc
(address)¶ Add carbon copy
-
add_ccs
(addresses)¶ Add carbon copy with array of addresses
-
add_file
(absolute_file_path)¶ Add attachment to email
-
encode
(value)¶ Encode parts of email to base64 for transfer
-
html
(html)¶ Set html content
-
send
()¶ Construct and execute sendemail.py script Finds python binary by os.py, then uses the /usr/bin/python to execute email script
-
subject
(subject)¶ Set email subject
-
text
(text)¶ Set text content
-
FormData¶
-
class
evernode.classes.
FormData
¶ -
add_field
(name, default=None, required=False, error=None)¶ Add a text/non-file field to parse for a value in the request
-
add_file
(name, required=False, error=None, extensions=None)¶ Add a file field to parse on request (uploads)
-
file_save
(name, filename=None, folder='', keep_ext=True) → bool¶ Easy save of a file
-
get_json_form_data
()¶ Load request Json Data, if any
-
parse
(fail_callback=None)¶ Parse text fields and file fields for values and files
-
Json¶
-
class
evernode.classes.
Json
(value)¶ help break down and construct json objects
-
camel_case
(snake_case)¶ Convert snake case to camel case
-
static
from_file
(file_path) → dict¶ Load JSON file
-
static
parse
(string, is_file=False, obj=False)¶ Convert a JSON string to dict/object
-
safe_object
() → dict¶ Create an object ready for JSON serialization
-
safe_values
(value)¶ Parse non-string values that will not serialize
-
static
string
(value) → str¶ string dict/object/value to JSON
-
JsonResponse¶
-
class
evernode.classes.
JsonResponse
(status_code=200, message=None, data=None, environ=None)¶ JsonResponse is a wrapper for BaseResponse
-
content
() → str¶ Get full content of response
-
data
(data=None)¶ Set response data
-
message
(message=None)¶ Set response message
-
mimetype
() → str¶ Return private minetype
-
quick_response
(status_code)¶ Quickly construct response using a status code
-
response
¶ alias of
flask.wrappers.Response
-
response_model
¶ alias of
evernode.models.response_model.ResponseModel
-
status
(status_code=None)¶ Set status or Get Status
-
JWT¶
-
class
evernode.classes.
JWT
¶ Gets request information to validate JWT
-
create_token
(data, token_valid_for=180) → str¶ Create encrypted JWT
-
create_token_with_refresh_token
(data, token_valid_for=180, refresh_token_valid_for=86400)¶ Create an encrypted JWT with a refresh_token
-
verify_http_auth_refresh_token
() → bool¶ Use expired token to check refresh token information
-
verify_http_auth_token
() → bool¶ Use request information to validate JWT
-
verify_refresh_token
(expired_token) → bool¶ Use request information to validate refresh JWT
-
verify_token
(token) → bool¶ Verify encrypted JWT
-
Middleware¶
-
class
evernode.classes.
Middleware
¶ Provides useful defaults for creating fast middleware
-
app
¶ alias of
flask.app.Flask
-
condition
() → bool¶ A condition to validate or invalidate a request
-
create_response
()¶ Default response for if condition is false(invalid)
-
response
¶ alias of
flask.wrappers.Response
-
Render¶
Security¶
-
class
evernode.classes.
Security
¶ Static functions to help app security
-
static
decrypt
(crypt_text) → str¶ Use config.json key to decrypt
-
static
encrypt
(clear_text) → str¶ Use config.json key to encrypt
-
static
generate_key
() → str¶ Generate a Fernet key
-
static
hash
(clear_text) → str¶ Hash clear text
-
static
random_string
(length) → str¶ Create a random string for security purposes
-
static
verify_hash
(clear_text, hashed_text) → bool¶ Check a hash
-
static
Session¶
-
class
evernode.classes.
Session
¶ Helper class for app state-less sessions
-
classmethod
create_session
(session_id, user_id)¶ Save a new session to the database Using the [‘AUTH’][‘MAX_SESSIONS’] config setting a session with be created within the MAX_SESSIONS limit. Once this limit is hit, delete the earliest session.
-
static
create_session_id
() → str¶ Create a session token
-
static
current_session
() → str¶ Return session id in app globals, only current request
-
static
set_current_session
(session_id) → bool¶ Add session_id to flask globals for current request
-
classmethod
Translator¶
-
class
evernode.classes.
Translator
(module_name=None, environ=None)¶ Uses dot-key syntax to translate phrases to words
-
trans
(key) → str¶ Root Example: Translator() Translator.trans(‘messages.hello’) resources/lang/en/messages.lang will be opened and parsed for { ‘hello’: ‘Some english text’ } If language is fr, resources/lang/fr/messages.lang will be opened and parsed for { ‘hello’: ‘Some french text’ } Module Example: Translator(‘[module-name]’) Translator.trans(‘messages.hello’)
-
Models¶
This part of the documentation covers all the models of EverNode.
BaseModel¶
-
class
evernode.models.
BaseModel
¶ Adds usefull custom attributes for applciation use
-
add
(name, value)¶ Add attribute
-
delete
()¶ Easy delete for db models
-
exists
()¶ Checks if item already exists in database
-
query_class
¶ alias of
flask_sqlalchemy.BaseQuery
-
remove
(name)¶ Remove attribute
-
save
()¶ Easy save(insert or update) for db models
-
updated
()¶ Update updated_at timestamp
-
classmethod
where_id
(id)¶ Get db model by id
-
BaseUserModel¶
-
class
evernode.models.
BaseUserModel
¶ User db model
-
add
(name, value)¶ Add attribute
-
classmethod
by_current_session
()¶ Returns current user session
-
classmethod
create_password_reset
(email, valid_for=3600) → str¶ Create a password reset request in the user_password_resets database table. Hashed code gets stored in the database. Returns unhashed reset code
-
delete
()¶ Easy delete for db models
-
exists
()¶ Checks if item already exists in database
-
query_class
¶ alias of
flask_sqlalchemy.BaseQuery
-
remove
(name)¶ Remove attribute
-
save
()¶ Easy save(insert or update) for db models
-
set_password
(password)¶ Set user password with hash
-
updated
()¶ Update updated_at timestamp
-
classmethod
validate_password_reset
(code, new_password)¶ Validates an unhashed code against a hashed code. Once the code has been validated and confirmed new_password will replace the old users password
-
classmethod
where_email
(email)¶ Get db model by email
-
classmethod
where_id
(id)¶ Get db model by id
-
DatabaseModel¶
JsonModel¶
PasswordResetModel¶
-
class
evernode.models.
PasswordResetModel
¶ Password Reset db Model
-
add
(name, value)¶ Add attribute
-
delete
()¶ Easy delete for db models
-
classmethod
delete_where_user_id
(user_id)¶ delete by email
-
exists
()¶ Checks if item already exists in database
-
query_class
¶ alias of
flask_sqlalchemy.BaseQuery
-
remove
(name)¶ Remove attribute
-
save
()¶ Easy save(insert or update) for db models
-
updated
()¶ Update updated_at timestamp
-
classmethod
where_code
(code)¶ get by code
-
classmethod
where_id
(id)¶ Get db model by id
-
classmethod
where_token
(token)¶ get by token
-
classmethod
where_user_id
(user_id)¶ get by user_id
-
ResponseModel¶
-
class
evernode.models.
ResponseModel
(status, message, data=None)¶ Class for a response a centralized response structure
SessionModel¶
-
class
evernode.models.
SessionModel
¶ class to handle db model for session
-
add
(name, value)¶ Add attribute
-
classmethod
count
(user_id)¶ Count sessions with user_id
-
delete
()¶ Easy delete for db models
-
exists
()¶ Checks if item already exists in database
-
query_class
¶ alias of
flask_sqlalchemy.BaseQuery
-
remove
(name)¶ Remove attribute
-
save
()¶ Easy save(insert or update) for db models
-
updated
()¶ Update updated_at timestamp
-
classmethod
where_earliest
(user_id)¶ Get earilest session by created_at timestamp
-
classmethod
where_id
(id)¶ Get db model by id
-
classmethod
where_lastest
(user_id)¶ Get lastest session by created_at timestamp
-
classmethod
where_session_id
(session_id)¶ Easy way to query by session id
-
classmethod
where_user_id
(user_id)¶ Easy way to query by user id
-
Decorators¶
This part of the documentation covers all the decorators of EverNode.
Functions¶
This part of the documentation covers all the functions of EverNode.
Scripts¶
This part of the documentation covers all the scripts of EverNode.
SendEmail¶
-
class
evernode.scripts.
SendEmail
¶ send email from the command line with async abilities
-
construct_message
(email=None)¶ construct the email message
-
create_email
()¶ main function to construct and send email
-
decode
(value)¶ decode args
-
multipart
¶ alias of
email.mime.multipart.MIMEMultipart
-
parse
()¶ parses args json
-
send
(email=None)¶ send email message
-
smtp
¶ alias of
smtplib.SMTP
-