This repository has been archived by the owner on Dec 13, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #99 from mostafa/feature/grest-cmd
feature/grest-cmd
- Loading branch information
Showing
25 changed files
with
167 additions
and
15 deletions.
There are no files selected for viewing
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
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,44 @@ | ||
#!/usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Copyright (C) 2017-2019 Mostafa Moradian <mostafamoradian0@gmail.com> | ||
# | ||
# This file is part of grest. | ||
# | ||
# grest is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# grest is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with grest. If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
|
||
import sys | ||
from cookiecutter.main import cookiecutter | ||
|
||
try: | ||
from pathlib import Path | ||
except ImportError: | ||
from pathlib2 import Path | ||
|
||
|
||
if __name__ == "__main__": | ||
try: | ||
if len(sys.argv) < 2: | ||
raise Exception("Usage: grest PROJECT_NAME") | ||
|
||
project_path = Path(sys.argv[1]).resolve() | ||
if project_path.exists(): | ||
raise Exception( | ||
"[ERROR] Directory exists. Consider using a different project name.") | ||
|
||
template = Path(__file__).resolve().parent.joinpath("template") | ||
cookiecutter(str(template), overwrite_if_exists=False) | ||
except Exception as e: | ||
print(str(e)) |
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,14 @@ | ||
{ | ||
"app_name": "api", | ||
"grest_version": "1.2.0", | ||
"DEBUG": false, | ||
"IP_ADDRESS": "localhost", | ||
"PORT": "5000", | ||
"NEO4J_USERNAME": "NEO4J", | ||
"NEO4J_PASSWORD": "NEO4J", | ||
"NEO4J_HOSTNAME": "localhost", | ||
"NEO4J_BOLT_PORT": 7687, | ||
"SECRET_KEY": "", | ||
"X_AUTH_TOKEN": "X-Auth-Token", | ||
"ENABLE_DELETE_ALL": 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# gREST Boilerplate | ||
|
||
## Install dependencies | ||
|
||
For installing dependencies, use the following command: | ||
|
||
```bash | ||
pip install -r requirements.txt | ||
``` | ||
|
||
## Running application | ||
|
||
For running the application, use the following command: | ||
|
||
```bash | ||
python main.py | ||
``` |
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,17 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
import os | ||
|
||
DEBUG = os.getenv("DEBUG", {{cookiecutter.DEBUG}}) | ||
|
||
IP_ADDRESS = os.getenv("IP_ADDRESS", "{{cookiecutter.IP_ADDRESS}}") | ||
PORT = os.getenv("PORT", {{cookiecutter.PORT}}) | ||
|
||
VERSION = os.getenv("VERSION", "0.0.1") | ||
SECRET_KEY = os.getenv("SECRET_KEY", "{{cookiecutter.SECRET_KEY}}") | ||
DB_URL = os.getenv( | ||
"DB_URL", "bolt://{{cookiecutter.NEO4J_USERNAME}}:{{cookiecutter.NEO4J_PASSWORD}}@{{cookiecutter.NEO4J_HOSTNAME}}:{{cookiecutter.NEO4J_BOLT_PORT}}") | ||
|
||
X_AUTH_TOKEN = "{{cookiecutter.X_AUTH_TOKEN}}" | ||
ENABLE_DELETE_ALL = os.getenv( | ||
"ENABLE_DELETE_ALL", "{{cookiecutter.ENABLE_DELETE_ALL}}") |
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 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
import neomodel | ||
from flask import Flask | ||
|
||
import config | ||
from users import UsersView | ||
|
||
|
||
if __name__ == "__main__": | ||
app = Flask(__name__) | ||
|
||
neomodel.config.DATABASE_URL = config.DB_URL | ||
neomodel.config.AUTO_INSTALL_LABELS = True | ||
|
||
UsersView.register(app, route_base="/users", trailing_slash=False) | ||
|
||
app.run(debug=config.DEBUG, | ||
host=config.IP_ADDRESS, | ||
port=config.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 @@ | ||
pygrest=={{cookiecutter.grest_version}} |
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,19 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from neomodel import StringProperty, StructuredNode, UniqueIdProperty | ||
from webargs import fields | ||
from grest import models | ||
|
||
|
||
class User(StructuredNode, models.Node): | ||
""" | ||
Person model | ||
""" | ||
__validation_rules__ = { | ||
"username": fields.Str(), | ||
"password": fields.Str() | ||
} | ||
|
||
uid = UniqueIdProperty() | ||
username = StringProperty() | ||
password = StringProperty() |
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,9 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from grest import GRest | ||
from schema import User | ||
|
||
|
||
class UsersView(GRest): | ||
__models__ = {"primary": User} | ||
__selection_field__ = {"primary": "uid"} |
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
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
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
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
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
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
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
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
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
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
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 |
---|---|---|
|
@@ -14,3 +14,5 @@ webargs==5.1.1 | |
Werkzeug==0.14.1 | ||
PyYAML==4.2b4 | ||
simplejson==3.16.0 | ||
pathlib2==2.3.3 | ||
cookiecutter==1.6.0 |
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
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
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
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