-
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.
Merge pull request #6 from JoshuaOndieki/develop
Tested API version v1.0
- Loading branch information
Showing
28 changed files
with
1,239 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
env/ | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
|
||
# 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/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# pytest | ||
.pytest_cache | ||
|
||
# pyenv | ||
.python-version | ||
|
||
# celery beat schedule file | ||
celerybeat-schedule | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# dotenv | ||
.env | ||
|
||
# virtualenv | ||
.venv | ||
venv/ | ||
ENV/ | ||
|
||
# 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,11 @@ | ||
language: python | ||
python: | ||
- "3.6" | ||
# command to install dependencies | ||
install: | ||
- pip install -r requirements.txt | ||
|
||
# command to run tests | ||
script: nosetests --with-coverage --cover-package=weconnect && coveralls | ||
|
||
after_success: coveralls |
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 @@ | ||
web: gunicorn app:app |
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,8 @@ | ||
from weconnect import create_app | ||
|
||
|
||
app = create_app('development') | ||
|
||
|
||
if __name__ == "__main__": | ||
app.run() |
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,27 @@ | ||
import os | ||
basedir = os.path.abspath(os.path.dirname(__file__)) | ||
|
||
|
||
class Config: | ||
""" | ||
Application configuration | ||
""" | ||
SECRET_KEY = 'secret' | ||
WTF_CSRF_ENABLED = False | ||
|
||
|
||
class DevelopmentConfig(Config): | ||
DEBUG = True | ||
|
||
|
||
class ProductionConfig(Config): | ||
DEBUG = False | ||
|
||
|
||
class TestingConfig(Config): | ||
DEBUG = True | ||
|
||
|
||
config = {'development': DevelopmentConfig, | ||
'testing': TestingConfig, | ||
'production': ProductionConfig} |
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 @@ | ||
aniso8601==2.0.1 | ||
attrs==17.4.0 | ||
certifi==2018.1.18 | ||
chardet==3.0.4 | ||
click==6.7 | ||
coverage==4.5.1 | ||
coveralls==1.3.0 | ||
docopt==0.6.2 | ||
Flask==0.12.2 | ||
Flask-JWT-Extended==3.7.1 | ||
Flask-RESTful==0.3.6 | ||
gunicorn==19.7.1 | ||
idna==2.6 | ||
itsdangerous==0.24 | ||
Jinja2==2.10 | ||
MarkupSafe==1.0 | ||
nose==1.3.7 | ||
pluggy==0.6.0 | ||
py==1.5.2 | ||
PyJWT==1.6.0 | ||
pytest==3.4.2 | ||
pytz==2018.3 | ||
requests==2.18.4 | ||
six==1.11.0 | ||
urllib3==1.22 | ||
Werkzeug==0.14.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 @@ | ||
python-3.6.4 |
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,53 @@ | ||
from flask import Flask | ||
from config import config | ||
from .api.v1.routes import v1 | ||
from flask_jwt_extended import JWTManager | ||
|
||
|
||
# multi dimentional dict storing app data in form of objects | ||
database = {"Users": {}, "Businesses": {}, "Reviews": {}} | ||
|
||
""" | ||
---------------------- DATA STRUCTURE ----------------- | ||
{ | ||
Users: | ||
{ | ||
userx: [email, password] | ||
... | ||
} | ||
Businesses: | ||
{ | ||
bsx: [name, location, category, userid] | ||
... | ||
} | ||
Reviews: | ||
{ | ||
revx: [content, bsid, userid] | ||
... | ||
} | ||
} | ||
""" | ||
|
||
|
||
def create_app(config_name): | ||
""" | ||
Usage: Factory function used to setup the application instance | ||
:return: application instance | ||
""" | ||
app = Flask(__name__) | ||
app.database = database | ||
app.config.from_object(config[config_name]) | ||
app.config['JWT_SECRET_KEY'] = 'super-secret' | ||
app.config['JWT_BLACKLIST_ENABLED'] = True | ||
app.config['JWT_BLACKLIST_TOKEN_CHECKS'] = ['access', 'refresh'] | ||
app.jwt = JWTManager(app) | ||
app.blacklist = set() | ||
|
||
@app.jwt.token_in_blacklist_loader | ||
def check_if_token_in_blacklist(decrypted_token): | ||
jti = decrypted_token['jti'] | ||
return jti in app.blacklist | ||
app.register_blueprint(v1, url_prefix="/api/v1") | ||
return app |
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,23 @@ | ||
from flask import Blueprint | ||
from flask_restful import Api | ||
from weconnect import resources as r | ||
|
||
|
||
v1 = Blueprint('v1', __name__) | ||
api = Api(v1) | ||
add = api.add_resource | ||
|
||
|
||
add(r.All, '/all') # GET | ||
# User Routes | ||
add(r.UserRegistration, '/auth/register') # POST | ||
add(r.UserLogin, '/auth/login') # POST | ||
add(r.UserLogout, '/auth/logout') # POST | ||
add(r.UserResetPassword, '/auth/reset-password') # POST | ||
|
||
# Business Routes | ||
add(r.Business, '/businesses') # GET, POST | ||
add(r.BusinessHandler, '/businesses/<int:businessId>') # GET, PUT, DEL | ||
|
||
# Review Routes | ||
add(r.Reviews, '/businesses/<int:businessId>/reviews') # GET, POST |
Oops, something went wrong.