Giter VIP home page Giter VIP logo

user-configuration-control's Introduction

USER CONFIGURATION CONTROL

project to upload and save configuration files. Associate conf with user.

Requirements

  • Python 3.6
  • requests
  • aiohttp
  • pyyaml
  • pymongo
  • aiomongodel
  • motor
  • mongo

API

  • POST /api/v1/users/ - data = 'name=12345' create user and generate api token. Return User model: json Username and Token. Example:
        curl --location --request POST 'http://localhost:8000/api/v1/users/' \
        --form 'name=12345'
    
  • GET /api/v1/users/<user_id>/configurations/ - search in the database in the collection of configurations that the user is a member
  • GET /api/v1/configuration/ - returns a list of all configuration
  • POST /api/v1/configuration/ data =files={"configuration": ("filename", "binar data"} - save configuration with empty list users. Data is Multipart/form-data file. If file saved return 201 status code. Example:
    import requests
    requests.post(
                "http://localhost:8000/api/v1/files/",
                files={"configuration": ("MyConf.conf", "[Main]\nEntryPoint=entry.py".encode())},
                headers={"Authorization": f"Token MySercretToken"},
            )
  • GET /api/v1/files/<id_configuration>/download - download conf file by id
  • PUT /api/v1/files/<id_configuration>/users/<user_id>} - add user to list users in configuration. Example:
    curl --location --request PUT 'http://localhost:8000/api/v1/configurations/5fce7c5e84fc379b2b23f275/users/5fce7bf684fc379b2b23f274' \
    --header 'Authorization: Token 6a4fc8ec-3930-1334-a333-640b8454e2e1'

How to run

  1. Up docker-compose
    docker-compose up

or:

  1. Run mongo (you may use docker for this):
    docker run --rm -p 27017:27017 -d mongo
  2. Run server:
    python entry.py

Configuration

Args:

param default description
--host Host to listen 0.0.0.0
--port Port to accept connections 8000
--reload Autoreload code on change"
-c, --config Path to configuration file

Settings:

configuration file has yaml format:

  • site_name - site name by defalt is "Control configure site"
  • database_uri - url format path to db by default mongodb://localhost:27017
  • media_dir - folder to save users file by defalt is media in project folder
  • hash_method - used hash function from hashlib. By default sha1

Testing

install via pip:

  • pytest
  • pytest-asyncio
pip install pytest pytest-asyncio

in project dir run pytest:

python -m pytest

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.