Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Enhanced existing code base, create flask restful api moderate #21

Merged
merged 1 commit into from
Nov 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
160 changes: 160 additions & 0 deletions myte/templates/template-flask-restful-api-moderate/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-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/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# 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/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
7 changes: 7 additions & 0 deletions myte/templates/template-flask-restful-api-moderate/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# myte_simple_flask_restful_api_template

## Features

## Contribution

## Contact
44 changes: 44 additions & 0 deletions myte/templates/template-flask-restful-api-moderate/api/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# config.py

"""
This module defines...
"""

# imports

import os

from dotenv import load_dotenv

# configurations

load_dotenv()

DATABASE_USERNAME = os.getenv('DATABASE_USERNAME')
DATABASE_PASSWORD = os.getenv('DATABASE_PASSWORD')
DATABASE_HOST = os.getenv('DATABASE_HOST')
DATABASE_PORT = os.getenv('DATABASE_PORT')
DATABASE_NAME = os.getenv('DATABASE_NAME')

DEBUG = True

# databases
# delete any database you don't want to use

# postgreSQL - default (pip install psycopg2 (windows users) or psycopg2-binary (linux and mac users)) # noqa

SQLALCHEMY_DATABASE_URI = f'postgresql://{DATABASE_USERNAME}:{DATABASE_PASSWORD}@{DATABASE_HOST}:{DATABASE_PORT}/{DATABASE_NAME}' # noqa

# # mySQL (pip install mysql-connector-python)
# uncomment line 35 to use MySQL DB and comment line 30

# SQLALCHEMY_DATABASE_URI = f'mysql://{DATABASE_USERNAME}:{DATABASE_PASSWORD}@{DATABASE_HOST}:{DATABASE_PORT}/{DATABASE_NAME}' # noqa

# # SQLite (goto https://www.sqlite.org/download.html, download and install, if you've not) # noqa
# uncomment line 40 to use SQLite DB and comment line 30

SQLALCHEMY_DATABASE_URI = f'sqlite:///{DATABASE_NAME}.db'

SQLALCHEMY_TRACK_MODIFICATIONS = False

SECRET_KEY = os.getenv('SECRETKEY')
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# imports
from flask_sqlalchemy import SQLAlchemy

# configurations
db = SQLAlchemy()

from .todo import Todo
from .todo_item import TodoItem
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# todo.py

"""
The model ...
"""

# imports

from datetime import datetime

from . import db

# pylint: disable=R0903


class Todo(db.Model):

"""
todo model class representing ....
"""

__tablename__ = "todos"

id = db.Column(db.Integer, primary_key=True)
title = db.Column(db.String(), nullable=False)
description = db.Column(db.String(), nullable=True)
status = db.Column(db.Boolean(), nullable=False)

created_at = db.Column(db.DateTime(), default=datetime.utcnow)
updated_at = db.Column(
db.DateTime(), default=datetime.utcnow, onupdate=datetime.utcnow,
nullable=True)

# relationships

todo_item = db.relationship("TodoItem", backref="todos", lazy=True)
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# todo_item.py

"""
The model ...
"""

# imports

from datetime import datetime

from . import db

# pylint: disable=R0903


class TodoItem(db.Model):

"""
todo item model class representing ....
"""

__tablename__ = "todo_items"

id = db.Column(db.Integer, primary_key=True)
task = db.Column(db.String(), nullable=False)
description = db.Column(db.String(), nullable=True)
status = db.Column(db.Boolean(), nullable=False)

created_at = db.Column(db.DateTime(), default=datetime.utcnow)
updated_at = db.Column(
db.DateTime(), default=datetime.utcnow, onupdate=datetime.utcnow,
nullable=True)

# foreign keys

todo_id = db.Column(db.Integer, db.ForeignKey(
'todos.id'), nullable=False)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .index import Index
from .todo import Todo
from .todo_item import TodoItem
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# index.py
"""
The module defines ....
"""

from flask_restful import Resource


class Index(Resource):
""" This class defines... """

def get(self):
""" This function defines... """

return {'hello': 'world'}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# todo.py
"""
The module defines ....
"""

from flask_restful import Resource


class Todo(Resource):
""" This class defines... """

def create(self):
""" This function defines... """

return

def view_all(self):
""" This function defines... """

return

def view_one(self, id):
""" This function defines... """

return

def update(self, id):
""" This function defines... """

return

def delete(self, id):
""" This function defines... """

return
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# todo_item.py
"""
The module defines ....
"""

from flask_restful import Resource


class TodoItem(Resource):
""" This class defines... """

def create(self):
""" This function defines... """

return

def view_all(self):
""" This function defines... """

return

def view_one(self, id):
""" This function defines... """

return

def update(self, id):
""" This function defines... """

return

def delete(self, id):
""" This function defines... """

return
Empty file.
Loading