forked from entrepreneur-interet-general/solidata_backend
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 99a8b20
Showing
34 changed files
with
1,071 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# config_prod | ||
config_prod.py | ||
|
||
# snippets folder | ||
_snippets/ | ||
|
||
# logs | ||
*.log | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Flask stuff | ||
# .flaskenv | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# pyenv | ||
.python-version | ||
|
||
# celery beat schedule file | ||
celerybeat-schedule | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2018 Entrepreneurs d’Intérêt Général | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<h1 align=center> SOLIDATA <br> backend</h1> | ||
|
||
|
||
------- | ||
## PRESENTATION | ||
|
||
A public service to allow you to open data as simple as posible | ||
|
||
|
||
------ | ||
|
||
## TECHNICAL POINTS | ||
|
||
#### Tech stack | ||
- _Language_ : **Python3**... yes ... I know ... hmmm ... gnnn ... don't judge me ? | ||
- _Framework_ : **[Flask](http://flask.pocoo.org/)**... minimalistic Python framework | ||
- _API_ : **[Flask-RestPlus](http://flask-restplus.readthedocs.io/en/stable/)**... Swagger documentation integrated |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# -*- encoding: utf-8 -*- | ||
|
||
""" | ||
appserver.py | ||
- creates an application instance and runs the dev server | ||
""" | ||
|
||
import os | ||
|
||
### + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ### | ||
### SET LOGGER | ||
### + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ### | ||
|
||
from log_config import log, pformat | ||
# log.debug('>>> TESTING LOGGER') | ||
|
||
|
||
### + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ### | ||
### RUN APPSERVER | ||
### + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ### | ||
|
||
if __name__ == '__main__': | ||
|
||
""" | ||
runner for the SOLIDATA backend Flask app | ||
in command line just type : | ||
"python appserver.py" | ||
""" | ||
|
||
log.debug("\n--- STARTING SOLIDATA API ---\n") | ||
|
||
from solidata_api.application import create_app | ||
|
||
app = create_app() | ||
|
||
app_port = int(app.config["DOMAIN_PORT"]) | ||
app_host = app.config["DOMAIN_ROOT"] | ||
app_debug = app.config["DEBUG"] | ||
|
||
|
||
# simple flask runner | ||
print("== "*30) | ||
app.run( debug=app_debug, host=app_host, port=app_port, threaded=True ) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
from pprint import pprint, pformat | ||
|
||
import logging | ||
from logging.config import dictConfig | ||
|
||
import colorlog | ||
from colorlog import ColoredFormatter | ||
|
||
|
||
# cf : https://stackoverflow.com/questions/17668633/what-is-the-point-of-setlevel-in-a-python-logging-handler | ||
|
||
### create a formatter for future logger | ||
formatter = ColoredFormatter( | ||
"%(log_color)s%(levelname)1.1s ::: %(name)s %(asctime)s ::: %(module)s:%(lineno)d -in- %(funcName)s ::: %(reset)s %(white)s%(message)s", | ||
datefmt='%y-%m-%d %H:%M:%S', | ||
reset=True, | ||
log_colors={ | ||
'DEBUG': 'cyan', | ||
'INFO': 'green', | ||
'WARNING': 'yellow', | ||
'ERROR': 'red', | ||
'CRITICAL': 'red,bg_white', | ||
}, | ||
secondary_log_colors={}, | ||
style='%' | ||
) | ||
|
||
### create handler | ||
handler = colorlog.StreamHandler() | ||
handler.setFormatter(formatter) | ||
|
||
### create logger | ||
log = colorlog.getLogger("log") | ||
log.addHandler(handler) | ||
|
||
### set logging level | ||
log.setLevel(logging.DEBUG) | ||
|
||
log_file_I = logging.handlers.RotatingFileHandler('logs/info_logs.log') | ||
log_file_I.setFormatter(formatter) | ||
log_file_I.setLevel(logging.INFO) | ||
log.addHandler(log_file_I) | ||
|
||
log_file_W = logging.handlers.RotatingFileHandler('logs/warning_logs.log') | ||
log_file_W.setFormatter(formatter) | ||
log_file_W.setLevel(logging.INFO) | ||
log.addHandler(log_file_W) |
Empty file.
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
aniso8601==3.0.0 | ||
bcrypt==3.1.4 | ||
blinker==1.4 | ||
certifi==2018.4.16 | ||
cffi==1.11.5 | ||
chardet==3.0.4 | ||
click==6.7 | ||
colorlog==3.1.4 | ||
Flask==1.0.2 | ||
Flask-Admin==1.5.1 | ||
Flask-Login==0.4.1 | ||
Flask-Mail==0.9.1 | ||
Flask-PyMongo==0.5.2 | ||
flask-restplus==0.11.0 | ||
Flask-SocketIO==3.0.1 | ||
idna==2.7 | ||
itsdangerous==0.24 | ||
Jinja2==2.10 | ||
jsonschema==2.6.0 | ||
MarkupSafe==1.0 | ||
numpy==1.14.5 | ||
pandas==0.23.1 | ||
pycparser==2.18 | ||
PyJWT==1.6.4 | ||
pymongo==3.6.1 | ||
python-dateutil==2.7.3 | ||
python-dotenv==0.8.2 | ||
python-engineio==2.1.1 | ||
python-socketio==1.9.0 | ||
pytz==2018.4 | ||
requests==2.19.0 | ||
six==1.11.0 | ||
urllib3==1.23 | ||
Werkzeug==0.14.1 | ||
WTForms==2.2.1 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
Empty file.
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# -*- encoding: utf-8 -*- | ||
|
||
""" | ||
api_projects/__init__.py | ||
- provides the API endpoints for consuming and producing | ||
REST requests and responses | ||
""" | ||
|
||
from flask import Blueprint | ||
from flask_restplus import Api | ||
|
||
### create blueprint and api wrapper | ||
blueprint = Blueprint( 'api_projects', __name__) | ||
api = Api( blueprint, | ||
title="SOLIDATA - PROJECTS API", | ||
version="0.1", | ||
description="create, list, delete, edit... projects", | ||
doc='/documentation', | ||
default='projects_list' | ||
) | ||
|
||
### import data schemas | ||
### TO DO | ||
|
||
### mocking a project definition | ||
projects = [ | ||
{ | ||
"id" : 1, | ||
"proj_title" : "my project", | ||
"owner" : "email", | ||
"collaborators" : [], | ||
|
||
"datamodel" : "dfghjkl", # datamodel id in DB | ||
"datasets_inputs" : [], # list of datasets_input ids in DB | ||
"corr_dicts" : [], # list of corr_dict ids in DB | ||
|
||
"recipes" : { | ||
"on_datamodel" : {}, | ||
"on_datasets" : {}, | ||
"on_corr_dict" : {}, | ||
}, | ||
|
||
"dataset_output" : "", # unique dataset output id in DB | ||
|
||
"exports" : [], # description of exports settings | ||
|
||
} | ||
] | ||
|
||
|
||
### import api namespaces | ||
from .proj_list import api as api_proj_list | ||
|
||
### add namespaces to api wrapper | ||
api.add_namespace(api_proj_list) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# -*- encoding: utf-8 -*- | ||
|
||
""" | ||
proj_list.py | ||
- provides the API endpoints for consuming and producing | ||
REST requests and responses | ||
""" | ||
|
||
from flask_restplus import Namespace, Resource, fields | ||
|
||
from . import projects | ||
|
||
api = Namespace('projects_list', description='Projects list ') | ||
|
||
|
||
|
||
### ROUTES | ||
@api.route('/') | ||
class ProjectsList(Resource): | ||
|
||
# @api.marshal_with(project_model, envelope="projects_list") | ||
def get(self): | ||
""" | ||
list of all projects in db | ||
""" | ||
return projects |
Oops, something went wrong.