diff --git a/myte/create_project.py b/myte/create_project.py index 6b26a29..e1b620c 100644 --- a/myte/create_project.py +++ b/myte/create_project.py @@ -11,6 +11,7 @@ from rich import print as mprint from rich.console import Console from rich.text import Text +from secret_key_generator import GenerateSecretKey class CreateProject: @@ -62,11 +63,13 @@ def create_dir(project_name, selected_framework, selected_setup): mprint(messages["usage_message"]["environment_variable"]) mprint(Text(messages["usage_message"] ["database_configuration"], "cyan").wrap(console, 70)) + mprint( + f"""{messages["usage_message"]["secret_key_configuration"]}[red] -> {GenerateSecretKey.generate_secret_key()}[/red]""") # noqa mprint("\n") @staticmethod def create_files(selected_framework, selected_setup): - """ This function defines the creation of directory """ + """ This function defines the creation of files in same directory """ console = Console() @@ -118,4 +121,6 @@ def create_files(selected_framework, selected_setup): mprint(messages["usage_message"]["environment_variable"]) mprint(Text(messages["usage_message"] ["database_configuration"], "cyan").wrap(console, 70)) + mprint( + f"""{messages["usage_message"]["secret_key_configuration"]}[red] -> {GenerateSecretKey.generate_secret_key()}[/red]""") # noqa mprint("\n") diff --git a/myte/info.json b/myte/info.json index 4f87c10..9dd7358 100644 --- a/myte/info.json +++ b/myte/info.json @@ -31,7 +31,8 @@ "environment_variable": "[cyan] - Rename example.env to .env [/cyan]", - "database_configuration": " - Go to config.py, decide the database you want to use, uncomment it and run the pip instructions there" + "database_configuration": " - Go to config.py, decide the database you want to use, uncomment it and run the pip instructions there ", + "secret_key_configuration": "[cyan] - Go to .env, replace 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' in SECRETKEY with[/cyan]" }, "os":{ diff --git a/myte/secret_key_generator.py b/myte/secret_key_generator.py new file mode 100644 index 0000000..b8602f8 --- /dev/null +++ b/myte/secret_key_generator.py @@ -0,0 +1,21 @@ +# secret_key_generator.py + +""" +This module generates secret keys to used in the frameworks templates +""" + + +import secrets +import string + + +class GenerateSecretKey: + """ This class is use to generate secret key to be used for security + purposes """ + + def generate_secret_key(length=32): + """ The function generates a 32 character secret key """ + + alphabet = string.ascii_letters + string.digits + secret_key = ''.join(secrets.choice(alphabet) for _ in range(length)) + return secret_key diff --git a/myte/templates/template-flask-moderate/.gitignore b/myte/templates/template-flask-moderate/.gitignore new file mode 100644 index 0000000..68bc17f --- /dev/null +++ b/myte/templates/template-flask-moderate/.gitignore @@ -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/ diff --git a/myte/templates/template-flask-moderate/README.md b/myte/templates/template-flask-moderate/README.md new file mode 100644 index 0000000..302e07a --- /dev/null +++ b/myte/templates/template-flask-moderate/README.md @@ -0,0 +1,7 @@ +# myte_moderate_flask_template + +## Features + +## Contribution + +## Contact diff --git a/myte/templates/template-flask-moderate/example.env b/myte/templates/template-flask-moderate/example.env new file mode 100644 index 0000000..56a52eb --- /dev/null +++ b/myte/templates/template-flask-moderate/example.env @@ -0,0 +1,16 @@ +# database +DATABASE_HOST = '' +DATABASE_PORT = 5432 +DATABASE_USERNAME = '' +DATABASE_PASSWORD = '' +DATABASE_NAME = '' + +# application +APPHOST = '0.0.0.0' +APPPOST = 3000 + +# environment +ENVIRONMENT = 'dev' + +# security +SECRETKEY = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' diff --git a/myte/templates/template-flask-moderate/src/app.py b/myte/templates/template-flask-moderate/src/app.py new file mode 100644 index 0000000..d9f75ec --- /dev/null +++ b/myte/templates/template-flask-moderate/src/app.py @@ -0,0 +1,44 @@ +# app.py + +""" +This module defines... +""" + +# imports + +from flask import Flask, render_template +from flask_migrate import Migrate + +import config +from models import db + +# configurations + +app = Flask(__name__) + +app.debug = config.DEBUG +app.config['SQLALCHEMY_DATABASE_URI'] = config.SQLALCHEMY_DATABASE_URI +app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = config.SQLALCHEMY_TRACK_MODIFICATIONS # noqa +app.config['SECRET_KEY'] = config.SECRET_KEY + +db.init_app(app) +db.app = app +migrate = Migrate(app, db) + +# application + + +@app.route('/', methods=['GET']) +def index(): + """ This function defines... """ + + # write your logic here + + return render_template('pages/index.html'), 200 + +# entrypoint + + +if __name__ == "__main__": + app.debug = config.DEBUG + app.run() diff --git a/myte/templates/template-flask-moderate/src/auth.py b/myte/templates/template-flask-moderate/src/auth.py new file mode 100644 index 0000000..e69de29 diff --git a/myte/templates/template-flask-moderate/src/config.py b/myte/templates/template-flask-moderate/src/config.py new file mode 100644 index 0000000..b0d17f5 --- /dev/null +++ b/myte/templates/template-flask-moderate/src/config.py @@ -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') diff --git a/myte/templates/template-flask-moderate/src/forms.py b/myte/templates/template-flask-moderate/src/forms.py new file mode 100644 index 0000000..acc2dcc --- /dev/null +++ b/myte/templates/template-flask-moderate/src/forms.py @@ -0,0 +1,36 @@ +""" +This module defines all forms needed by the users +""" +# imports + +from flask_wtf import FlaskForm +from flask_wtf.file import FileAllowed, FileField +from wtforms import IntegerField, SelectField, StringField, SubmitField +from wtforms.validators import DataRequired, Email + + +# forms + + +class CreateUserForm(FlaskForm): + + """ This class is use to create new users """ + + name = StringField('Name', validators=[DataRequired()]) + email_address = StringField('Email Address', validators=[Email()]) + phone_number = IntegerField('Phone Number') + street_name = StringField('Street Name', validators=[DataRequired()]) + city = StringField('City', validators=[DataRequired()]) + state = StringField('State', validators=[DataRequired()]) + country = SelectField('Country', validators=[DataRequired()], choices=[]) + zipcode = StringField('Zipcode', validators=[DataRequired()]) + user_photo = FileField('Logo', validators=[FileAllowed( + ['jpg', 'png'], 'JPG & PNG Formats Only!')]) + create_user = SubmitField('Add user') + + +class DeleteUserForm(FlaskForm): + + """ This class is use to create new users """ + + delete_user = SubmitField('Yes') diff --git a/myte/templates/template-flask-moderate/src/models.py b/myte/templates/template-flask-moderate/src/models.py new file mode 100644 index 0000000..24372c3 --- /dev/null +++ b/myte/templates/template-flask-moderate/src/models.py @@ -0,0 +1,54 @@ +# models.py + +""" +This module defines... +""" + +# imports + +from datetime import datetime + +from flask_sqlalchemy import SQLAlchemy + +# configurations + +db = SQLAlchemy() + +# models + + +class Parent(db.Model): + ''' Defines the model for parent details''' + + __tablename__ = 'parents' + + id = db.Column(db.Integer, primary_key=True) + first_name = db.Column(db.String(), nullable=False) + middle_name = db.Column(db.String(), nullable=True) + last_name = db.Column(db.String(), nullable=False) + + created_at = db.Column(db.DateTime(), default=datetime.utcnow) + updated_at = db.Column(db.DateTime(), nullable=True, + onupdate=datetime.utcnow) + + # relationships + child = db.relationship("Child", backref="parents", lazy=True) + + +class Child(db.Model): + ''' Defines the model for child details''' + + __tablename__ = 'children' + + id = db.Column(db.Integer, primary_key=True) + first_name = db.Column(db.String(), nullable=False) + middle_name = db.Column(db.String(), nullable=True) + last_name = db.Column(db.String(), nullable=False) + + created_at = db.Column(db.DateTime(), default=datetime.utcnow) + updated_at = db.Column(db.DateTime(), nullable=True, + onupdate=datetime.utcnow) + + # foreign keys + parent_id = db.Column(db.Integer, db.ForeignKey( + "parents.id"), nullable=False) diff --git a/myte/templates/template-flask-moderate/src/static/css/css.css b/myte/templates/template-flask-moderate/src/static/css/css.css new file mode 100644 index 0000000..c0e2f75 --- /dev/null +++ b/myte/templates/template-flask-moderate/src/static/css/css.css @@ -0,0 +1,61 @@ +section { + overflow-x: hidden; +} + +.container { + background-color: rgb(15, 15, 15); + width: 100%; + min-height: 100vh; + box-sizing: border-box; + padding-top: 3%; + padding-left: 20%; + padding-right: 20%; +} + +@media (max-width: 768px) { + .container { + padding-left: 5%; + padding-right: 5%; + } +} + +.content { + display: flex; + justify-content: center; + align-items: flex-start; + gap: 2rem; +} + +.logo { + max-width: 100px; +} +.flask{ + max-width: 100px; + filter: invert(100%); +} + +.title { + color: white; + font-size: 1.8rem; + font-weight: 900; + letter-spacing: .5rem; + font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif; + text-align: center; +} + +.texts { + color: white; + font-size: 1rem; + font-family: Arial, Helvetica, sans-serif; + text-align: left; + letter-spacing: .12rem; + line-height: 1.5rem; +} + +.end { + color: white; + font-size: 1.2rem; + letter-spacing: .2rem; + font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif; + text-align: center; +} diff --git a/myte/templates/template-flask-moderate/src/static/img/favicon/android-icon-144x144.png b/myte/templates/template-flask-moderate/src/static/img/favicon/android-icon-144x144.png new file mode 100644 index 0000000..2ac4aca Binary files /dev/null and b/myte/templates/template-flask-moderate/src/static/img/favicon/android-icon-144x144.png differ diff --git a/myte/templates/template-flask-moderate/src/static/img/favicon/android-icon-192x192.png b/myte/templates/template-flask-moderate/src/static/img/favicon/android-icon-192x192.png new file mode 100644 index 0000000..474e988 Binary files /dev/null and b/myte/templates/template-flask-moderate/src/static/img/favicon/android-icon-192x192.png differ diff --git a/myte/templates/template-flask-moderate/src/static/img/favicon/android-icon-36x36.png b/myte/templates/template-flask-moderate/src/static/img/favicon/android-icon-36x36.png new file mode 100644 index 0000000..ee2b9d4 Binary files /dev/null and b/myte/templates/template-flask-moderate/src/static/img/favicon/android-icon-36x36.png differ diff --git a/myte/templates/template-flask-moderate/src/static/img/favicon/android-icon-48x48.png b/myte/templates/template-flask-moderate/src/static/img/favicon/android-icon-48x48.png new file mode 100644 index 0000000..3dba90d Binary files /dev/null and b/myte/templates/template-flask-moderate/src/static/img/favicon/android-icon-48x48.png differ diff --git a/myte/templates/template-flask-moderate/src/static/img/favicon/android-icon-72x72.png b/myte/templates/template-flask-moderate/src/static/img/favicon/android-icon-72x72.png new file mode 100644 index 0000000..a6978c7 Binary files /dev/null and b/myte/templates/template-flask-moderate/src/static/img/favicon/android-icon-72x72.png differ diff --git a/myte/templates/template-flask-moderate/src/static/img/favicon/android-icon-96x96.png b/myte/templates/template-flask-moderate/src/static/img/favicon/android-icon-96x96.png new file mode 100644 index 0000000..3efce18 Binary files /dev/null and b/myte/templates/template-flask-moderate/src/static/img/favicon/android-icon-96x96.png differ diff --git a/myte/templates/template-flask-moderate/src/static/img/favicon/apple-icon-114x114.png b/myte/templates/template-flask-moderate/src/static/img/favicon/apple-icon-114x114.png new file mode 100644 index 0000000..03e24df Binary files /dev/null and b/myte/templates/template-flask-moderate/src/static/img/favicon/apple-icon-114x114.png differ diff --git a/myte/templates/template-flask-moderate/src/static/img/favicon/apple-icon-120x120.png b/myte/templates/template-flask-moderate/src/static/img/favicon/apple-icon-120x120.png new file mode 100644 index 0000000..399037f Binary files /dev/null and b/myte/templates/template-flask-moderate/src/static/img/favicon/apple-icon-120x120.png differ diff --git a/myte/templates/template-flask-moderate/src/static/img/favicon/apple-icon-144x144.png b/myte/templates/template-flask-moderate/src/static/img/favicon/apple-icon-144x144.png new file mode 100644 index 0000000..2ac4aca Binary files /dev/null and b/myte/templates/template-flask-moderate/src/static/img/favicon/apple-icon-144x144.png differ diff --git a/myte/templates/template-flask-moderate/src/static/img/favicon/apple-icon-152x152.png b/myte/templates/template-flask-moderate/src/static/img/favicon/apple-icon-152x152.png new file mode 100644 index 0000000..c7775d4 Binary files /dev/null and b/myte/templates/template-flask-moderate/src/static/img/favicon/apple-icon-152x152.png differ diff --git a/myte/templates/template-flask-moderate/src/static/img/favicon/apple-icon-180x180.png b/myte/templates/template-flask-moderate/src/static/img/favicon/apple-icon-180x180.png new file mode 100644 index 0000000..5fa7bbb Binary files /dev/null and b/myte/templates/template-flask-moderate/src/static/img/favicon/apple-icon-180x180.png differ diff --git a/myte/templates/template-flask-moderate/src/static/img/favicon/apple-icon-57x57.png b/myte/templates/template-flask-moderate/src/static/img/favicon/apple-icon-57x57.png new file mode 100644 index 0000000..ebcb1b5 Binary files /dev/null and b/myte/templates/template-flask-moderate/src/static/img/favicon/apple-icon-57x57.png differ diff --git a/myte/templates/template-flask-moderate/src/static/img/favicon/apple-icon-60x60.png b/myte/templates/template-flask-moderate/src/static/img/favicon/apple-icon-60x60.png new file mode 100644 index 0000000..a127514 Binary files /dev/null and b/myte/templates/template-flask-moderate/src/static/img/favicon/apple-icon-60x60.png differ diff --git a/myte/templates/template-flask-moderate/src/static/img/favicon/apple-icon-72x72.png b/myte/templates/template-flask-moderate/src/static/img/favicon/apple-icon-72x72.png new file mode 100644 index 0000000..a6978c7 Binary files /dev/null and b/myte/templates/template-flask-moderate/src/static/img/favicon/apple-icon-72x72.png differ diff --git a/myte/templates/template-flask-moderate/src/static/img/favicon/apple-icon-76x76.png b/myte/templates/template-flask-moderate/src/static/img/favicon/apple-icon-76x76.png new file mode 100644 index 0000000..b540bba Binary files /dev/null and b/myte/templates/template-flask-moderate/src/static/img/favicon/apple-icon-76x76.png differ diff --git a/myte/templates/template-flask-moderate/src/static/img/favicon/apple-icon-precomposed.png b/myte/templates/template-flask-moderate/src/static/img/favicon/apple-icon-precomposed.png new file mode 100644 index 0000000..ab72c92 Binary files /dev/null and b/myte/templates/template-flask-moderate/src/static/img/favicon/apple-icon-precomposed.png differ diff --git a/myte/templates/template-flask-moderate/src/static/img/favicon/apple-icon.png b/myte/templates/template-flask-moderate/src/static/img/favicon/apple-icon.png new file mode 100644 index 0000000..ab72c92 Binary files /dev/null and b/myte/templates/template-flask-moderate/src/static/img/favicon/apple-icon.png differ diff --git a/myte/templates/template-flask-moderate/src/static/img/favicon/browserconfig.xml b/myte/templates/template-flask-moderate/src/static/img/favicon/browserconfig.xml new file mode 100644 index 0000000..c554148 --- /dev/null +++ b/myte/templates/template-flask-moderate/src/static/img/favicon/browserconfig.xml @@ -0,0 +1,2 @@ + +#ffffff \ No newline at end of file diff --git a/myte/templates/template-flask-moderate/src/static/img/favicon/favicon-16x16.png b/myte/templates/template-flask-moderate/src/static/img/favicon/favicon-16x16.png new file mode 100644 index 0000000..cd781e4 Binary files /dev/null and b/myte/templates/template-flask-moderate/src/static/img/favicon/favicon-16x16.png differ diff --git a/myte/templates/template-flask-moderate/src/static/img/favicon/favicon-32x32.png b/myte/templates/template-flask-moderate/src/static/img/favicon/favicon-32x32.png new file mode 100644 index 0000000..f8e0591 Binary files /dev/null and b/myte/templates/template-flask-moderate/src/static/img/favicon/favicon-32x32.png differ diff --git a/myte/templates/template-flask-moderate/src/static/img/favicon/favicon-96x96.png b/myte/templates/template-flask-moderate/src/static/img/favicon/favicon-96x96.png new file mode 100644 index 0000000..3efce18 Binary files /dev/null and b/myte/templates/template-flask-moderate/src/static/img/favicon/favicon-96x96.png differ diff --git a/myte/templates/template-flask-moderate/src/static/img/favicon/favicon.ico b/myte/templates/template-flask-moderate/src/static/img/favicon/favicon.ico new file mode 100644 index 0000000..b79b3c7 Binary files /dev/null and b/myte/templates/template-flask-moderate/src/static/img/favicon/favicon.ico differ diff --git a/myte/templates/template-flask-moderate/src/static/img/favicon/manifest.json b/myte/templates/template-flask-moderate/src/static/img/favicon/manifest.json new file mode 100644 index 0000000..013d4a6 --- /dev/null +++ b/myte/templates/template-flask-moderate/src/static/img/favicon/manifest.json @@ -0,0 +1,41 @@ +{ + "name": "App", + "icons": [ + { + "src": "\/android-icon-36x36.png", + "sizes": "36x36", + "type": "image\/png", + "density": "0.75" + }, + { + "src": "\/android-icon-48x48.png", + "sizes": "48x48", + "type": "image\/png", + "density": "1.0" + }, + { + "src": "\/android-icon-72x72.png", + "sizes": "72x72", + "type": "image\/png", + "density": "1.5" + }, + { + "src": "\/android-icon-96x96.png", + "sizes": "96x96", + "type": "image\/png", + "density": "2.0" + }, + { + "src": "\/android-icon-144x144.png", + "sizes": "144x144", + "type": "image\/png", + "density": "3.0" + }, + { + "src": "\/android-icon-192x192.png", + "sizes": "192x192", + "type": "image\/png", + "density": "4.0" + } + ] +} \ No newline at end of file diff --git a/myte/templates/template-flask-moderate/src/static/img/favicon/ms-icon-144x144.png b/myte/templates/template-flask-moderate/src/static/img/favicon/ms-icon-144x144.png new file mode 100644 index 0000000..2ac4aca Binary files /dev/null and b/myte/templates/template-flask-moderate/src/static/img/favicon/ms-icon-144x144.png differ diff --git a/myte/templates/template-flask-moderate/src/static/img/favicon/ms-icon-150x150.png b/myte/templates/template-flask-moderate/src/static/img/favicon/ms-icon-150x150.png new file mode 100644 index 0000000..bdf3655 Binary files /dev/null and b/myte/templates/template-flask-moderate/src/static/img/favicon/ms-icon-150x150.png differ diff --git a/myte/templates/template-flask-moderate/src/static/img/favicon/ms-icon-310x310.png b/myte/templates/template-flask-moderate/src/static/img/favicon/ms-icon-310x310.png new file mode 100644 index 0000000..d7a463c Binary files /dev/null and b/myte/templates/template-flask-moderate/src/static/img/favicon/ms-icon-310x310.png differ diff --git a/myte/templates/template-flask-moderate/src/static/img/favicon/ms-icon-70x70.png b/myte/templates/template-flask-moderate/src/static/img/favicon/ms-icon-70x70.png new file mode 100644 index 0000000..ad89cca Binary files /dev/null and b/myte/templates/template-flask-moderate/src/static/img/favicon/ms-icon-70x70.png differ diff --git a/myte/templates/template-flask-moderate/src/static/img/flask-logo-svg-vector.svg b/myte/templates/template-flask-moderate/src/static/img/flask-logo-svg-vector.svg new file mode 100644 index 0000000..4ca1ede --- /dev/null +++ b/myte/templates/template-flask-moderate/src/static/img/flask-logo-svg-vector.svg @@ -0,0 +1 @@ + diff --git a/myte/templates/template-flask-moderate/src/static/img/myte.png b/myte/templates/template-flask-moderate/src/static/img/myte.png new file mode 100644 index 0000000..601aeec Binary files /dev/null and b/myte/templates/template-flask-moderate/src/static/img/myte.png differ diff --git a/myte/templates/template-flask-moderate/src/static/js/js.js b/myte/templates/template-flask-moderate/src/static/js/js.js new file mode 100644 index 0000000..e69de29 diff --git a/myte/templates/template-flask-moderate/src/templates/layouts/main.html b/myte/templates/template-flask-moderate/src/templates/layouts/main.html new file mode 100644 index 0000000..d92c9de --- /dev/null +++ b/myte/templates/template-flask-moderate/src/templates/layouts/main.html @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {% block title %} {% endblock %} + + + + + + {% block content %} {% endblock %} + + + + + + \ No newline at end of file diff --git a/myte/templates/template-flask-moderate/src/templates/pages/index.html b/myte/templates/template-flask-moderate/src/templates/pages/index.html new file mode 100644 index 0000000..da1963d --- /dev/null +++ b/myte/templates/template-flask-moderate/src/templates/pages/index.html @@ -0,0 +1,40 @@ +{% extends "layouts/main.html" %} + +{% block title %} Myte - Simple Flask {% endblock %} + +{% block content %} + +
+
+ +
+

Myte + Flask

+
+
+

Your application is running smoothly

+

Please do take a look at your files and make changes as your desire. There are files your should take a + critical look at for proper configuration to suit what you want.

+
    +
  • app.py - This is your app entry point, and also where you define your routes & logic.
  • +
  • config.py - All configuration relating app, security and database are done here.
  • +
  • .env - Environment variable.
  • +
  • models.py - Defines your database tables.
  • +
+
+
+

Thank you for using Myte

+
+
+

Click on the myte and flask logos to learn more

+
+
+
+ +{% endblock %} \ No newline at end of file diff --git a/myte/templates/template-flask-moderate/src/utils.py b/myte/templates/template-flask-moderate/src/utils.py new file mode 100644 index 0000000..e69de29 diff --git a/myte/templates/template-flask-robust/.gitignore b/myte/templates/template-flask-robust/.gitignore new file mode 100644 index 0000000..68bc17f --- /dev/null +++ b/myte/templates/template-flask-robust/.gitignore @@ -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/ diff --git a/myte/templates/template-flask-robust/README.md b/myte/templates/template-flask-robust/README.md new file mode 100644 index 0000000..ffc55f6 --- /dev/null +++ b/myte/templates/template-flask-robust/README.md @@ -0,0 +1,7 @@ +# myte_robust_flask_template + +## Features + +## Contribution + +## Contact diff --git a/myte/templates/template-flask-robust/example.env b/myte/templates/template-flask-robust/example.env new file mode 100644 index 0000000..56a52eb --- /dev/null +++ b/myte/templates/template-flask-robust/example.env @@ -0,0 +1,16 @@ +# database +DATABASE_HOST = '' +DATABASE_PORT = 5432 +DATABASE_USERNAME = '' +DATABASE_PASSWORD = '' +DATABASE_NAME = '' + +# application +APPHOST = '0.0.0.0' +APPPOST = 3000 + +# environment +ENVIRONMENT = 'dev' + +# security +SECRETKEY = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' diff --git a/myte/templates/template-flask-robust/requirements.txt b/myte/templates/template-flask-robust/requirements.txt new file mode 100644 index 0000000..9da07a8 --- /dev/null +++ b/myte/templates/template-flask-robust/requirements.txt @@ -0,0 +1,19 @@ +alembic +blinker +click +colorama +Flask +Flask-Cors +Flask-Migrate +Flask-SQLAlchemy +Flask-WTF +greenlet +itsdangerous +Jinja2 +Mako +MarkupSafe +python-dotenv +SQLAlchemy +typing_extensions +Werkzeug +WTForms diff --git a/myte/templates/template-flask-robust/src/config.py b/myte/templates/template-flask-robust/src/config.py new file mode 100644 index 0000000..8965f1c --- /dev/null +++ b/myte/templates/template-flask-robust/src/config.py @@ -0,0 +1,47 @@ +""" +This module define all important variables, connection to DB +""" + +# imports + +import os + +from dotenv import load_dotenv + +# configurations + +load_dotenv() + +DATABASE_HOST = os.getenv('DATABASE_HOST') +DATABASE_PORT = os.getenv('DATABASE_PORT') +DATABASE_USERNAME = os.getenv('DATABASE_USERNAME') +DATABASE_PASSWORD = os.getenv('DATABASE_PASSWORD') +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_MODIFICATIONS_TRACKS = False + +appHost = os.getenv('APPHOST') +appPort = os.getenv('APPPORT') + +environment = os.getenv('ENVIRONMENT') + +secretKey = os.getenv('SECRETKEY') diff --git a/myte/templates/template-flask-robust/src/forms/__init__.py b/myte/templates/template-flask-robust/src/forms/__init__.py new file mode 100644 index 0000000..c329f37 --- /dev/null +++ b/myte/templates/template-flask-robust/src/forms/__init__.py @@ -0,0 +1,4 @@ +from flask_wtf.csrf import CSRFProtect +from .user import CreateUserForm, DeleteUserForm + +csrf = CSRFProtect() diff --git a/myte/templates/template-flask-robust/src/forms/user.py b/myte/templates/template-flask-robust/src/forms/user.py new file mode 100644 index 0000000..acc2dcc --- /dev/null +++ b/myte/templates/template-flask-robust/src/forms/user.py @@ -0,0 +1,36 @@ +""" +This module defines all forms needed by the users +""" +# imports + +from flask_wtf import FlaskForm +from flask_wtf.file import FileAllowed, FileField +from wtforms import IntegerField, SelectField, StringField, SubmitField +from wtforms.validators import DataRequired, Email + + +# forms + + +class CreateUserForm(FlaskForm): + + """ This class is use to create new users """ + + name = StringField('Name', validators=[DataRequired()]) + email_address = StringField('Email Address', validators=[Email()]) + phone_number = IntegerField('Phone Number') + street_name = StringField('Street Name', validators=[DataRequired()]) + city = StringField('City', validators=[DataRequired()]) + state = StringField('State', validators=[DataRequired()]) + country = SelectField('Country', validators=[DataRequired()], choices=[]) + zipcode = StringField('Zipcode', validators=[DataRequired()]) + user_photo = FileField('Logo', validators=[FileAllowed( + ['jpg', 'png'], 'JPG & PNG Formats Only!')]) + create_user = SubmitField('Add user') + + +class DeleteUserForm(FlaskForm): + + """ This class is use to create new users """ + + delete_user = SubmitField('Yes') diff --git a/myte/templates/template-flask-robust/src/models/__init__.py b/myte/templates/template-flask-robust/src/models/__init__.py new file mode 100644 index 0000000..02778eb --- /dev/null +++ b/myte/templates/template-flask-robust/src/models/__init__.py @@ -0,0 +1,9 @@ +# imports +from flask_sqlalchemy import SQLAlchemy + +# configurations +db = SQLAlchemy() + +# moduel imports +from .user import User +from .sibling import Sibling diff --git a/myte/templates/template-flask-robust/src/models/abc.py b/myte/templates/template-flask-robust/src/models/abc.py new file mode 100644 index 0000000..b550b5d --- /dev/null +++ b/myte/templates/template-flask-robust/src/models/abc.py @@ -0,0 +1,79 @@ +""" +Define an Abstract Base Class (ABC) for models +""" +from datetime import datetime +from weakref import WeakValueDictionary + +from sqlalchemy import inspect +from sqlalchemy.orm import aliased + +from . import db + + +class MetaBaseModel(db.Model.__class__): + """ Define a metaclass for the BaseModel + Implement `__getitem__` for managing aliases """ + + def __init__(cls, *args): + super().__init__(*args) + cls.aliases = WeakValueDictionary() + + def __getitem__(cls, key): + try: + alias = cls.aliases[key] + except KeyError: + alias = aliased(cls) + cls.aliases[key] = alias + return alias + + +class BaseModel: + """ Generalize __init__, __repr__ and to_json + Based on the models columns """ + + print_filter = ('password') + to_json_filter = ('password') + + def __repr__(self): + """ Define a base way to print models + Columns inside `print_filter` are excluded """ + return "%s(%s)" % ( + self.__class__.__name__, + { + column: value + for column, value in self._to_dict().items() + if column not in self.print_filter + }, + ) + + @property + def json(self): + """ Define a base way to jsonify models + Columns inside `to_json_filter` are excluded """ + return { + column: value + if not isinstance(value, datetime) + else value.strftime("%Y-%m-%d") + for column, value in self._to_dict().items() + if column not in self.to_json_filter + } + + def _to_dict(self): + """ This would more or less be the same as a `to_json` + But putting it in a "private" function + Allows to_json to be overriden without impacting __repr__ + Or the other way around + And to add filter lists """ + return { + column.key: getattr(self, column.key) + for column in inspect(self.__class__).attrs + } + + def save(self): + db.session.add(self) + db.session.commit() + return self + + def delete(self): + db.session.delete(self) + db.session.commit() diff --git a/myte/templates/template-flask-robust/src/models/sibling.py b/myte/templates/template-flask-robust/src/models/sibling.py new file mode 100644 index 0000000..aa4e218 --- /dev/null +++ b/myte/templates/template-flask-robust/src/models/sibling.py @@ -0,0 +1,38 @@ +""" +The model represents a user entity with attributes such as name, +address,contact information, and registration details, associated with contact +persons and jobs. +""" + +# imports + +from datetime import datetime + +from . import db +from .abc import BaseModel, MetaBaseModel + +# pylint: disable=R0903 + + +class Sibling(db.Model, BaseModel, metaclass=MetaBaseModel): + + """ + user model class representing the 'users' table in the database. + """ + + __tablename__ = "siblings" + + id = db.Column(db.Integer, primary_key=True) + full_name = db.Column(db.String(), nullable=False) + email_address = db.Column(db.String(), unique=True, nullable=True) + phone_number = db.Column(db.String(), 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 + + user_id = db.Column(db.Integer, db.ForeignKey( + 'users.id'), nullable=False) diff --git a/myte/templates/template-flask-robust/src/models/user.py b/myte/templates/template-flask-robust/src/models/user.py new file mode 100644 index 0000000..73c7868 --- /dev/null +++ b/myte/templates/template-flask-robust/src/models/user.py @@ -0,0 +1,45 @@ +""" +The model represents a user entity with attributes such as name, +address,contact information, and registration details, associated with contact +persons and jobs. +""" + +# imports + +from datetime import datetime + +from . import db +from .abc import BaseModel, MetaBaseModel + +# pylint: disable=R0903 + + +class User(db.Model, BaseModel, metaclass=MetaBaseModel): + + """ + user model class representing the 'users' table in the database. + """ + + __tablename__ = "users" + + id = db.Column(db.Integer, primary_key=True) + name = db.Column(db.String(), nullable=False) + email_address = db.Column(db.String(), unique=True, nullable=True) + phone_number = db.Column(db.String(), unique=True, nullable=True) + street_name = db.Column(db.String(), nullable=False) + city = db.Column(db.String(), nullable=False) + state = db.Column(db.String(), nullable=False) + country = db.Column(db.String(), nullable=False) + zipcode = db.Column(db.Integer(), nullable=False) + user_photo = db.Column(db.String(), nullable=True) + + created_at = db.Column(db.DateTime(), default=datetime.utcnow) + updated_at = db.Column( + db.DateTime(), default=datetime.utcnow, onupdate=datetime.utcnow, + nullable=True + ) + + # relationships + + siblings = db.relationship( + "Sibling", backref="users", lazy=True) diff --git a/myte/templates/template-flask-robust/src/resources/__init__.py b/myte/templates/template-flask-robust/src/resources/__init__.py new file mode 100644 index 0000000..10ac414 --- /dev/null +++ b/myte/templates/template-flask-robust/src/resources/__init__.py @@ -0,0 +1,5 @@ +""" +Imports for all resources +""" + +from .index import IndexResource diff --git a/myte/templates/template-flask-robust/src/resources/index.py b/myte/templates/template-flask-robust/src/resources/index.py new file mode 100644 index 0000000..0e4ed63 --- /dev/null +++ b/myte/templates/template-flask-robust/src/resources/index.py @@ -0,0 +1,22 @@ +""" +This module defines the resource for the index page +""" + + +from flask import render_template + +# pylint: disable=R0903 + + +class IndexResource: + + """ Index Resources """ + + # pylint: disable=E0211 + + def index(): + """ Confirms and displays basic info that the server is running """ + + pass + + return render_template('pages/index/index.html'), 200 diff --git a/myte/templates/template-flask-robust/src/routes/__init__.py b/myte/templates/template-flask-robust/src/routes/__init__.py new file mode 100644 index 0000000..d158a43 --- /dev/null +++ b/myte/templates/template-flask-robust/src/routes/__init__.py @@ -0,0 +1,5 @@ +""" +Imports for all blueprints +""" + +from .index import index_blueprint diff --git a/myte/templates/template-flask-robust/src/routes/index.py b/myte/templates/template-flask-robust/src/routes/index.py new file mode 100644 index 0000000..21f88a8 --- /dev/null +++ b/myte/templates/template-flask-robust/src/routes/index.py @@ -0,0 +1,11 @@ +""" +This defines the routes for Homepage +""" + +from flask import Blueprint + +from resources import IndexResource + +index_blueprint = Blueprint("index", __name__) + +index_blueprint.route("/")(IndexResource.index) diff --git a/myte/templates/template-flask-robust/src/server.py b/myte/templates/template-flask-robust/src/server.py new file mode 100644 index 0000000..68d7977 --- /dev/null +++ b/myte/templates/template-flask-robust/src/server.py @@ -0,0 +1,50 @@ +""" +This module defines the server configuration required to run the app +successfully. + +# Configuration defined +Server as Flask APP +Flask Blueprint +Flask SQLAlchemy for DB +Flask Migrate for DB-ORM +CSRF Protection +Error Handling +""" +# imports + + +from flask import Blueprint, Flask +from flask_migrate import Migrate +from flask_cors import CORS + +import config +import routes +from models import db +from forms import csrf + +# configurations + +server = Flask(__name__) + +server.config['SECRET_KEY'] = config.secretKey + +server.config['SQLALCHEMY_DATABASE_URI'] = config.SQLALCHEMY_DATABASE_URI +server.config['SQLALCHEMY_MODIFICATIONS_TRACKS'] = config.SQLALCHEMY_MODIFICATIONS_TRACKS # noqa + +db.init_app(server) +db.app = (server) +migrate = Migrate(server, db) +WTF_CSRF_SECRET_KEY = config.secretKey +csrf.init_app(server) + +cors = CORS(server, resources={ + r"/*": {"origins": "http://127.0.0.1:5000"}}) + +for blueprint in vars(routes).values(): + if isinstance(blueprint, Blueprint): + server.register_blueprint(blueprint) + +# application run +if __name__ == "__main__": + server.debug = config.DEBUG + server.run() diff --git a/myte/templates/template-flask-robust/src/static/css/css.css b/myte/templates/template-flask-robust/src/static/css/css.css new file mode 100644 index 0000000..c0e2f75 --- /dev/null +++ b/myte/templates/template-flask-robust/src/static/css/css.css @@ -0,0 +1,61 @@ +section { + overflow-x: hidden; +} + +.container { + background-color: rgb(15, 15, 15); + width: 100%; + min-height: 100vh; + box-sizing: border-box; + padding-top: 3%; + padding-left: 20%; + padding-right: 20%; +} + +@media (max-width: 768px) { + .container { + padding-left: 5%; + padding-right: 5%; + } +} + +.content { + display: flex; + justify-content: center; + align-items: flex-start; + gap: 2rem; +} + +.logo { + max-width: 100px; +} +.flask{ + max-width: 100px; + filter: invert(100%); +} + +.title { + color: white; + font-size: 1.8rem; + font-weight: 900; + letter-spacing: .5rem; + font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif; + text-align: center; +} + +.texts { + color: white; + font-size: 1rem; + font-family: Arial, Helvetica, sans-serif; + text-align: left; + letter-spacing: .12rem; + line-height: 1.5rem; +} + +.end { + color: white; + font-size: 1.2rem; + letter-spacing: .2rem; + font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif; + text-align: center; +} diff --git a/myte/templates/template-flask-robust/src/static/img/favicon/android-icon-144x144.png b/myte/templates/template-flask-robust/src/static/img/favicon/android-icon-144x144.png new file mode 100644 index 0000000..2ac4aca Binary files /dev/null and b/myte/templates/template-flask-robust/src/static/img/favicon/android-icon-144x144.png differ diff --git a/myte/templates/template-flask-robust/src/static/img/favicon/android-icon-192x192.png b/myte/templates/template-flask-robust/src/static/img/favicon/android-icon-192x192.png new file mode 100644 index 0000000..474e988 Binary files /dev/null and b/myte/templates/template-flask-robust/src/static/img/favicon/android-icon-192x192.png differ diff --git a/myte/templates/template-flask-robust/src/static/img/favicon/android-icon-36x36.png b/myte/templates/template-flask-robust/src/static/img/favicon/android-icon-36x36.png new file mode 100644 index 0000000..ee2b9d4 Binary files /dev/null and b/myte/templates/template-flask-robust/src/static/img/favicon/android-icon-36x36.png differ diff --git a/myte/templates/template-flask-robust/src/static/img/favicon/android-icon-48x48.png b/myte/templates/template-flask-robust/src/static/img/favicon/android-icon-48x48.png new file mode 100644 index 0000000..3dba90d Binary files /dev/null and b/myte/templates/template-flask-robust/src/static/img/favicon/android-icon-48x48.png differ diff --git a/myte/templates/template-flask-robust/src/static/img/favicon/android-icon-72x72.png b/myte/templates/template-flask-robust/src/static/img/favicon/android-icon-72x72.png new file mode 100644 index 0000000..a6978c7 Binary files /dev/null and b/myte/templates/template-flask-robust/src/static/img/favicon/android-icon-72x72.png differ diff --git a/myte/templates/template-flask-robust/src/static/img/favicon/android-icon-96x96.png b/myte/templates/template-flask-robust/src/static/img/favicon/android-icon-96x96.png new file mode 100644 index 0000000..3efce18 Binary files /dev/null and b/myte/templates/template-flask-robust/src/static/img/favicon/android-icon-96x96.png differ diff --git a/myte/templates/template-flask-robust/src/static/img/favicon/apple-icon-114x114.png b/myte/templates/template-flask-robust/src/static/img/favicon/apple-icon-114x114.png new file mode 100644 index 0000000..03e24df Binary files /dev/null and b/myte/templates/template-flask-robust/src/static/img/favicon/apple-icon-114x114.png differ diff --git a/myte/templates/template-flask-robust/src/static/img/favicon/apple-icon-120x120.png b/myte/templates/template-flask-robust/src/static/img/favicon/apple-icon-120x120.png new file mode 100644 index 0000000..399037f Binary files /dev/null and b/myte/templates/template-flask-robust/src/static/img/favicon/apple-icon-120x120.png differ diff --git a/myte/templates/template-flask-robust/src/static/img/favicon/apple-icon-144x144.png b/myte/templates/template-flask-robust/src/static/img/favicon/apple-icon-144x144.png new file mode 100644 index 0000000..2ac4aca Binary files /dev/null and b/myte/templates/template-flask-robust/src/static/img/favicon/apple-icon-144x144.png differ diff --git a/myte/templates/template-flask-robust/src/static/img/favicon/apple-icon-152x152.png b/myte/templates/template-flask-robust/src/static/img/favicon/apple-icon-152x152.png new file mode 100644 index 0000000..c7775d4 Binary files /dev/null and b/myte/templates/template-flask-robust/src/static/img/favicon/apple-icon-152x152.png differ diff --git a/myte/templates/template-flask-robust/src/static/img/favicon/apple-icon-180x180.png b/myte/templates/template-flask-robust/src/static/img/favicon/apple-icon-180x180.png new file mode 100644 index 0000000..5fa7bbb Binary files /dev/null and b/myte/templates/template-flask-robust/src/static/img/favicon/apple-icon-180x180.png differ diff --git a/myte/templates/template-flask-robust/src/static/img/favicon/apple-icon-57x57.png b/myte/templates/template-flask-robust/src/static/img/favicon/apple-icon-57x57.png new file mode 100644 index 0000000..ebcb1b5 Binary files /dev/null and b/myte/templates/template-flask-robust/src/static/img/favicon/apple-icon-57x57.png differ diff --git a/myte/templates/template-flask-robust/src/static/img/favicon/apple-icon-60x60.png b/myte/templates/template-flask-robust/src/static/img/favicon/apple-icon-60x60.png new file mode 100644 index 0000000..a127514 Binary files /dev/null and b/myte/templates/template-flask-robust/src/static/img/favicon/apple-icon-60x60.png differ diff --git a/myte/templates/template-flask-robust/src/static/img/favicon/apple-icon-72x72.png b/myte/templates/template-flask-robust/src/static/img/favicon/apple-icon-72x72.png new file mode 100644 index 0000000..a6978c7 Binary files /dev/null and b/myte/templates/template-flask-robust/src/static/img/favicon/apple-icon-72x72.png differ diff --git a/myte/templates/template-flask-robust/src/static/img/favicon/apple-icon-76x76.png b/myte/templates/template-flask-robust/src/static/img/favicon/apple-icon-76x76.png new file mode 100644 index 0000000..b540bba Binary files /dev/null and b/myte/templates/template-flask-robust/src/static/img/favicon/apple-icon-76x76.png differ diff --git a/myte/templates/template-flask-robust/src/static/img/favicon/apple-icon-precomposed.png b/myte/templates/template-flask-robust/src/static/img/favicon/apple-icon-precomposed.png new file mode 100644 index 0000000..ab72c92 Binary files /dev/null and b/myte/templates/template-flask-robust/src/static/img/favicon/apple-icon-precomposed.png differ diff --git a/myte/templates/template-flask-robust/src/static/img/favicon/apple-icon.png b/myte/templates/template-flask-robust/src/static/img/favicon/apple-icon.png new file mode 100644 index 0000000..ab72c92 Binary files /dev/null and b/myte/templates/template-flask-robust/src/static/img/favicon/apple-icon.png differ diff --git a/myte/templates/template-flask-robust/src/static/img/favicon/browserconfig.xml b/myte/templates/template-flask-robust/src/static/img/favicon/browserconfig.xml new file mode 100644 index 0000000..c554148 --- /dev/null +++ b/myte/templates/template-flask-robust/src/static/img/favicon/browserconfig.xml @@ -0,0 +1,2 @@ + +#ffffff \ No newline at end of file diff --git a/myte/templates/template-flask-robust/src/static/img/favicon/favicon-16x16.png b/myte/templates/template-flask-robust/src/static/img/favicon/favicon-16x16.png new file mode 100644 index 0000000..cd781e4 Binary files /dev/null and b/myte/templates/template-flask-robust/src/static/img/favicon/favicon-16x16.png differ diff --git a/myte/templates/template-flask-robust/src/static/img/favicon/favicon-32x32.png b/myte/templates/template-flask-robust/src/static/img/favicon/favicon-32x32.png new file mode 100644 index 0000000..f8e0591 Binary files /dev/null and b/myte/templates/template-flask-robust/src/static/img/favicon/favicon-32x32.png differ diff --git a/myte/templates/template-flask-robust/src/static/img/favicon/favicon-96x96.png b/myte/templates/template-flask-robust/src/static/img/favicon/favicon-96x96.png new file mode 100644 index 0000000..3efce18 Binary files /dev/null and b/myte/templates/template-flask-robust/src/static/img/favicon/favicon-96x96.png differ diff --git a/myte/templates/template-flask-robust/src/static/img/favicon/favicon.ico b/myte/templates/template-flask-robust/src/static/img/favicon/favicon.ico new file mode 100644 index 0000000..b79b3c7 Binary files /dev/null and b/myte/templates/template-flask-robust/src/static/img/favicon/favicon.ico differ diff --git a/myte/templates/template-flask-robust/src/static/img/favicon/manifest.json b/myte/templates/template-flask-robust/src/static/img/favicon/manifest.json new file mode 100644 index 0000000..013d4a6 --- /dev/null +++ b/myte/templates/template-flask-robust/src/static/img/favicon/manifest.json @@ -0,0 +1,41 @@ +{ + "name": "App", + "icons": [ + { + "src": "\/android-icon-36x36.png", + "sizes": "36x36", + "type": "image\/png", + "density": "0.75" + }, + { + "src": "\/android-icon-48x48.png", + "sizes": "48x48", + "type": "image\/png", + "density": "1.0" + }, + { + "src": "\/android-icon-72x72.png", + "sizes": "72x72", + "type": "image\/png", + "density": "1.5" + }, + { + "src": "\/android-icon-96x96.png", + "sizes": "96x96", + "type": "image\/png", + "density": "2.0" + }, + { + "src": "\/android-icon-144x144.png", + "sizes": "144x144", + "type": "image\/png", + "density": "3.0" + }, + { + "src": "\/android-icon-192x192.png", + "sizes": "192x192", + "type": "image\/png", + "density": "4.0" + } + ] +} \ No newline at end of file diff --git a/myte/templates/template-flask-robust/src/static/img/favicon/ms-icon-144x144.png b/myte/templates/template-flask-robust/src/static/img/favicon/ms-icon-144x144.png new file mode 100644 index 0000000..2ac4aca Binary files /dev/null and b/myte/templates/template-flask-robust/src/static/img/favicon/ms-icon-144x144.png differ diff --git a/myte/templates/template-flask-robust/src/static/img/favicon/ms-icon-150x150.png b/myte/templates/template-flask-robust/src/static/img/favicon/ms-icon-150x150.png new file mode 100644 index 0000000..bdf3655 Binary files /dev/null and b/myte/templates/template-flask-robust/src/static/img/favicon/ms-icon-150x150.png differ diff --git a/myte/templates/template-flask-robust/src/static/img/favicon/ms-icon-310x310.png b/myte/templates/template-flask-robust/src/static/img/favicon/ms-icon-310x310.png new file mode 100644 index 0000000..d7a463c Binary files /dev/null and b/myte/templates/template-flask-robust/src/static/img/favicon/ms-icon-310x310.png differ diff --git a/myte/templates/template-flask-robust/src/static/img/favicon/ms-icon-70x70.png b/myte/templates/template-flask-robust/src/static/img/favicon/ms-icon-70x70.png new file mode 100644 index 0000000..ad89cca Binary files /dev/null and b/myte/templates/template-flask-robust/src/static/img/favicon/ms-icon-70x70.png differ diff --git a/myte/templates/template-flask-robust/src/static/img/flask-logo-svg-vector.svg b/myte/templates/template-flask-robust/src/static/img/flask-logo-svg-vector.svg new file mode 100644 index 0000000..4ca1ede --- /dev/null +++ b/myte/templates/template-flask-robust/src/static/img/flask-logo-svg-vector.svg @@ -0,0 +1 @@ + diff --git a/myte/templates/template-flask-robust/src/static/img/myte.png b/myte/templates/template-flask-robust/src/static/img/myte.png new file mode 100644 index 0000000..601aeec Binary files /dev/null and b/myte/templates/template-flask-robust/src/static/img/myte.png differ diff --git a/myte/templates/template-flask-robust/src/templates/errors/404.html b/myte/templates/template-flask-robust/src/templates/errors/404.html new file mode 100644 index 0000000..3bdd7fa --- /dev/null +++ b/myte/templates/template-flask-robust/src/templates/errors/404.html @@ -0,0 +1,28 @@ +{% extends "layouts/main.html" %} +{% block title %} Page Not Found {% endblock %} +{% block content %} + +
+
+

+ + +

+

+ 404 ERROR +

+

+ The page you trying to view is not available. Please check the url you enter and try + again or click on the button below to go back home +

+

+

+ Go back Home + +
+

+
+
+ +{% endblock %} \ No newline at end of file diff --git a/myte/templates/template-flask-robust/src/templates/errors/500.html b/myte/templates/template-flask-robust/src/templates/errors/500.html new file mode 100644 index 0000000..4dc4913 --- /dev/null +++ b/myte/templates/template-flask-robust/src/templates/errors/500.html @@ -0,0 +1,22 @@ +{% extends "layouts/main.html" %} +{% block title %} Page Not Found | Wealthmax Capital {% endblock %} +{% block content %} + +
+
+

+ + +

+

+ 500 ERROR +

+

+ The page you trying to view is not available. If this error persist, please send a + mail to contact@xyz.com +

+
+
+ +{% endblock %} \ No newline at end of file diff --git a/myte/templates/template-flask-robust/src/templates/forms/createaccount.html b/myte/templates/template-flask-robust/src/templates/forms/createaccount.html new file mode 100644 index 0000000..fa83b82 --- /dev/null +++ b/myte/templates/template-flask-robust/src/templates/forms/createaccount.html @@ -0,0 +1,103 @@ +{% extends "layouts/auth.html" %} +{% block title %} Create Account {% endblock %} +{% block content %} +

+ Create an Account! +

+
+ {{ form.hidden_tag() }} + {% with messages = get_flashed_messages(category_filter=["error"]) %} + {% if messages %} + {% for message in messages %} + + {% endfor %} + {% endif %} + {% endwith %} + {% with messages = get_flashed_messages(category_filter=["success"]) %} + {% if messages %} + {% for message in messages %} + + {% endfor %} + {% endif %} + {% endwith %} +
+ + {{form.firstname(class="form-control", type="text", id="firstName", placeholder="First Name")}} + +
+ Looks good! +
+
+ Please input your first name +
+
+
+ + {{form.lastname(type="text", class="form-control", id="lastName", placeholder="Last Name")}} + +
+ Looks good! +
+
+ Please input your last name. +
+
+
+ + {{form.email(class="form-control", type="email", id="email", placeholder="name@example.com")}} + +
+ Looks good! +
+
+ Please input a valid email address. +
+
+
+ + {{form.password1(type="password", class="form-control", id="password", placeholder="Password")}} + +
+ Looks good! +
+
+ Please choose a valid password. +
+
+
+ + {{form.password2(type="password", class="form-control", id="repeatPassword", placeholder="Repeat Password", + onkeyup="matchPassword()")}} + +
+ Looks good! +
+ +

The password did not match

+
+
+ Please repeat your password above. +
+
+ +

+ By clicking on 'Create Account' button you agree to the Terms of Service and Privacy Policy. +

+ +
+ + {{form.submit(type="submit", class="btn btn-th w-100 btn-lg")}} +
+
+
+ Already have an Account? Login! +
+
+
+{% endblock %} \ No newline at end of file diff --git a/myte/templates/template-flask-robust/src/templates/forms/login.html b/myte/templates/template-flask-robust/src/templates/forms/login.html new file mode 100644 index 0000000..0f39f05 --- /dev/null +++ b/myte/templates/template-flask-robust/src/templates/forms/login.html @@ -0,0 +1,64 @@ +{% extends "layouts/auth.html" %} +{% block title %} Login {% endblock %} +{% block content %} + +

+ Welcome Back! +

+

+ Login to your Dashboard +

+ +
+ {{ form.hidden_tag() }} + {% with messages = get_flashed_messages(category_filter=["error"]) %} + {% if messages %} + {% for message in messages %} + + {% endfor %} + {% endif %} + {% endwith %} + {% with messages = get_flashed_messages(category_filter=["success"]) %} + {% if messages %} + {% for message in messages %} + + {% endfor %} + {% endif %} + {% endwith %} +
+ + {{form.email(type="email", class="form-control", id="floatingInput", placeholder="name@example.com")}} + +
+
+ + {{form.password(type="password", class="form-control", id="floatingPassword", placeholder="Password")}} + +
+
+ + {{form.remember(class="form-check-input", type="checkbox", value="", id="flexCheckChecked")}} + +
+
+ + {{form.submit(type="submit", class="btn btn-th w-100 btn-lg")}} +
+
+ +
+ Create an Account! +
+
+
+{% endblock %} \ No newline at end of file diff --git a/myte/templates/template-flask-robust/src/templates/layouts/main.html b/myte/templates/template-flask-robust/src/templates/layouts/main.html new file mode 100644 index 0000000..d92c9de --- /dev/null +++ b/myte/templates/template-flask-robust/src/templates/layouts/main.html @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {% block title %} {% endblock %} + + + + + + {% block content %} {% endblock %} + + + + + + \ No newline at end of file diff --git a/myte/templates/template-flask-robust/src/templates/pages/index/index.html b/myte/templates/template-flask-robust/src/templates/pages/index/index.html new file mode 100644 index 0000000..c921bd1 --- /dev/null +++ b/myte/templates/template-flask-robust/src/templates/pages/index/index.html @@ -0,0 +1,47 @@ +{% extends "layouts/main.html" %} + +{% block title %} Myte - Simple Flask {% endblock %} + +{% block content %} + +
+
+ +
+

Myte + Flask

+
+
+

Your application is running smoothly

+

Please do take a look at your files/directories and make changes as your desire. There are files your + should take a + critical look at for proper configuration to suit what you want.

+
    +
  • server.py - This is your app entry point, and also where you define your routes & logic.
  • +
  • config.py - All configuration relating app, security and database are done here.
  • +
  • .env - Environment variable.
  • +
  • forms/ - Defines forms if needed for your project.
  • +
  • middlewares/ - Defines things like auth, logging, caching and other functions to be mounted in your + app.
  • +
  • resources/ - Defines your logics/functions.
  • +
  • routes/ - Defines the routes to your logic/functions.
  • +
  • models/ - Defines your database tables.
  • +
  • utils/ - Defines other necessary utilities. e.g. Errors.
  • +
+
+
+

Thank you for using Myte

+
+
+

Click on the myte and flask logos to learn more

+
+
+
+ +{% endblock %} \ No newline at end of file diff --git a/myte/templates/template-flask-robust/src/utils/__init__.py b/myte/templates/template-flask-robust/src/utils/__init__.py new file mode 100644 index 0000000..d8fb7d2 --- /dev/null +++ b/myte/templates/template-flask-robust/src/utils/__init__.py @@ -0,0 +1,2 @@ +from .errors import (BadRequest, Conflict, DataNotFound, Forbidden, + InternalServerError, Unauthorized, TooManyRequest, MethodNotAllowed) diff --git a/myte/templates/template-flask-robust/src/utils/errors.py b/myte/templates/template-flask-robust/src/utils/errors.py new file mode 100644 index 0000000..6aa5d0b --- /dev/null +++ b/myte/templates/template-flask-robust/src/utils/errors.py @@ -0,0 +1,78 @@ +""" +## Module Name: error.py + +This module contains error handling configurations. + +""" + + +class BadRequest(Exception): + """ This class represents a 400 bad request """ + + def __init__(self) -> None: + self.code = 400 + self.type = 'Bad Request' + self.message = 'A bad request error has occurred. A missing required parameters, or invalid data has caused this error.' # noqa + + +class Unauthorized(Exception): + """ This class represents a 401 unauthorized request """ + + def __init__(self) -> None: + self.code = 401 + self.type = 'Unauthorized Request' + self.message = 'An unauthorized request was made. The API requires authentication and the user fails to provide valid credentials, this error will occur.' # noqa + + +class Forbidden(Exception): + """ This class represents a 403 unauthorized request """ + + def __init__(self) -> None: + self.code = 403 + self.type = 'Forbidden Request' + self.message = 'A forbidden request was made. The request was not authorized to perform the requested operation. This may indicate that the client lacks the necessary permissions or credentials' # noqa + + +class DataNotFound(Exception): + """ This class represents a 404 not found error """ + + def __init__(self) -> None: + self.code = 404 + self.type = 'Not Found' + self.message = 'Data was not found.' + + +class MethodNotAllowed(Exception): + """ This class represents a 405 method not allowed error """ + + def __init__(self) -> None: + self.code = 405 + self.type = 'Method not Allowed' + self.message = 'The HTTP method used for the request is not supported for the requested resource.' # noqa + + +class Conflict(Exception): + """ This class represents a 409 conflict error """ + + def __init__(self) -> None: + self.code = 409 + self.type = 'Conflict Error' + self.message = 'Conflict with data.This error occurs if the requested POST operation conflicts with the current state of the server' # noqa + + +class TooManyRequest(Exception): + """ This class represents a 429 too many requests error """ + + def __init__(self) -> None: + self.code = 429 + self.type = 'Too Many Requests' + self.message = 'Too many requests where made within a given time frame, and the server is rate-limiting the to prevent abuse of API' # noqa + + +class InternalServerError(Exception): + """ This class represents a 500 internal server error """ + + def __init__(self) -> None: + self.code = 500 + self.type = 'Internal Server Error' + self.message = 'An internal server error has occurred. If this message persist please contact customer support.' # noqa diff --git a/myte/templates/template-flask-simple/config.py b/myte/templates/template-flask-simple/config.py index 6724bfa..b0d17f5 100644 --- a/myte/templates/template-flask-simple/config.py +++ b/myte/templates/template-flask-simple/config.py @@ -25,19 +25,19 @@ # databases # delete any database you don't want to use -# postgreSQL - default (pip install psycopg2 or psycopg2-binary) +# 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 psycopg2 or psycopg2-binary) -# uncomment to use +# # mySQL (pip install mysql-connector-python) +# uncomment line 35 to use MySQL DB and comment line 30 -# SQLALCHEMY_DATABASE_URI = f'postgresql://{DATABASE_USERNAME}:{DATABASE_PASSWORD}@{DATABASE_HOST}:{DATABASE_PORT}/{DATABASE_NAME}' # noqa +# SQLALCHEMY_DATABASE_URI = f'mysql://{DATABASE_USERNAME}:{DATABASE_PASSWORD}@{DATABASE_HOST}:{DATABASE_PORT}/{DATABASE_NAME}' # noqa -# # SQLite (pip install psycopg2 or psycopg2-binary) -# uncomment to use +# # 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'postgresql://{DATABASE_USERNAME}:{DATABASE_PASSWORD}@{DATABASE_HOST}:{DATABASE_PORT}/{DATABASE_NAME}' # noqa +# SQLALCHEMY_DATABASE_URI = f'sqlite:///{DATABASE_NAME}.db' SQLALCHEMY_TRACK_MODIFICATIONS = False diff --git a/myte/templates/template-flask-simple/example.env b/myte/templates/template-flask-simple/example.env index 0e56427..2e2465f 100644 --- a/myte/templates/template-flask-simple/example.env +++ b/myte/templates/template-flask-simple/example.env @@ -6,4 +6,4 @@ DATABASE_PORT = 5432 DATABASE_NAME = '' # security -SECRETKEY = '' +SECRETKEY = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' diff --git a/myte/templates/template-flask-simple/requirements.txt b/myte/templates/template-flask-simple/requirements.txt index 405961f..940d4e6 100644 --- a/myte/templates/template-flask-simple/requirements.txt +++ b/myte/templates/template-flask-simple/requirements.txt @@ -10,7 +10,6 @@ itsdangerous Jinja2 Mako MarkupSafe -psycopg2-binary python-dotenv SQLAlchemy typing_extensions