Skip to content

Instantly share code, notes, and snippets.

View aguilard07's full-sized avatar

Daniel Aguilar López aguilard07

View GitHub Profile
{
"user": {
"admin": false,
"id": 2,
"username": "test2"
}
}
#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
@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
{
"username": "test",
"password": "test123"
}
{
"users": [
{
"admin": false,
"id": 1,
"username": "test"
},
{
"admin": false,
"id": 2,
# 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
----
-- 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",
#
# 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
@aguilard07
aguilard07 / app.py
Last active November 20, 2021 13:04
# 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,
)
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