This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"user": { | |
"admin": false, | |
"id": 2, | |
"username": "test2" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Get user by id | |
@app.route("/user/<int:id>", methods=["GET"]) | |
def get_user_by_id(id): | |
user = User.query.filter_by(id=id).first() | |
if not user: | |
return jsonify({"message": "Not user found."}), 404 | |
else: | |
user_data = {} | |
user_data["id"] = user.id | |
user_data["username"] = user.username |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@app.route("/user/<int:id>", methods=["GET"]) | |
def get_user_by_id(id): | |
user = User.query.filter_by(id=id).first() | |
if not user: | |
return jsonify({"message": "Not user found."}), 404 | |
else: | |
user_data = {} | |
user_data["id"] = user.id | |
user_data["username"] = user.username | |
user_data["admin"] = user.admin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"username": "test", | |
"password": "test123" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"users": [ | |
{ | |
"admin": false, | |
"id": 1, | |
"username": "test" | |
}, | |
{ | |
"admin": false, | |
"id": 2, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# List users | |
@app.route("/user", methods=["GET"]) | |
def get_all_users(): | |
users = User.query.all() | |
output = [] | |
for user in users: | |
user_data = {} | |
user_data["id"] = user.id | |
user_data["username"] = user.username | |
user_data["admin"] = user.admin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
---- | |
-- User configuration file for lsyncd. | |
-- | |
-- Simple example for default rsync, but executing moves through on the target. | |
-- | |
-- For more examples, see /usr/share/doc/lsyncd*/examples/ | |
-- | |
-- sync{default.rsyncssh, source="/var/www/html", host="localhost", targetdir="/tmp/htmlcopy/"} | |
settings { | |
logident = "lsyncd", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Monitor file $1 for changes | |
# Send an alert emai to $2 if file $1 changes | |
# usage: inotify_email_watcher.sh /var/log/messages your.name@domain.com | |
if [ -z "$2" ]; then | |
echo "Usage: inotify_email_watcher.sh" | |
exit 1 | |
fi | |
# if the file exists | |
if [ -f $1 ] || [ -d $1 ]; then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create users | |
@app.route("/user", methods=["POST"]) | |
def create_user(): | |
data = request.get_json() | |
hashed_password = generate_password_hash(data["password"], method="sha256") | |
new_user = User( | |
username=data["username"], | |
password=hashed_password, | |
admin=False, | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from dotenv import load_dotenv | |
from flask import Flask, jsonify, request, make_response | |
from flask_sqlalchemy import SQLAlchemy | |
from functools import wraps | |
from flask import Flask, jsonify, request, make_response | |
from flask_sqlalchemy import SQLAlchemy | |
from functools import wraps | |
from werkzeug.security import check_password_hash, generate_password_hash | |
import datetime | |
import jwt |