project to upload and save configuration files. Associate conf with user.
- Python 3.6
- requests
- aiohttp
- pyyaml
- pymongo
- aiomongodel
- motor
- mongo
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 memberGET /api/v1/configuration/
- returns a list of all configurationPOST /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 idPUT /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'
- Up docker-compose
docker-compose up
or:
- Run mongo (you may use docker for this):
docker run --rm -p 27017:27017 -d mongo
- Run server:
python entry.py
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 |
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:27017media_dir
- folder to save users file by defalt is media in project folderhash_method
- used hash function from hashlib. By default sha1
install via pip:
- pytest
- pytest-asyncio
pip install pytest pytest-asyncio
in project dir run pytest:
python -m pytest