Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
elhawlir committed Jan 20, 2022
0 parents commit 1cc443b
Show file tree
Hide file tree
Showing 45 changed files with 13,561 additions and 0 deletions.
180 changes: 180 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
### Python ###
# 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/
pip-wheel-metadata/
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/
pytestdebug.log

# 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/
doc/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.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

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

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
pythonenv*

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# profiling data
.prof

### VisualStudioCode ###
.vscode/*
!.vscode/tasks.json
!.vscode/launch.json
*.code-workspace

### VisualStudioCode Patch ###
# Ignore all local history of files
.history
.ionide

### Windows ###
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db

# Dump file
*.stackdump

# Folder config file
[Dd]esktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp

# Windows shortcuts
*.lnk

# specific files and folders I don't want uploaded
c_buildr/.gcloudignore
c_buildr/config.py
c_buildr/main.py
cloudbuild.yaml
c_buildr/emails.py

19 changes: 19 additions & 0 deletions app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
runtime: python38

handlers:
# This configures Google App Engine to serve the files in the app's static
# directory.
- url: /static
static_dir: c_buildr/static/

# This handler routes all requests not caught above to your main app. It is
# required when static routes are defined, but can be omitted (along with
# the entire handlers section) when there are no static files defined.
- url: /.*
script: auto
secure: always
redirect_http_response_code: 301

# warmup requests to reduce latency
inbound_services:
- warmup
2 changes: 2 additions & 0 deletions c_buildr/.flaskenv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FLASK_APP=main
FLASK_ENV=development
4 changes: 4 additions & 0 deletions c_buildr/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Flask Template Ecommerce site



38 changes: 38 additions & 0 deletions c_buildr/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from flask import Flask

from .config import (
CLOUD_SQL_CONNECTION_NAME,
CLOUD_SQL_DATABASE_NAME,
CLOUD_SQL_PASSWORD,
CLOUD_SQL_USERNAME,
SQLALCHEMY_DATABASE_URI,
)

# import flask_login
from flask_login import LoginManager
# from werkzeug.security import generate_password_hash, check_password_hash
from flask_cors import CORS
from flask_sqlalchemy import SQLAlchemy
from flask_migrate import Migrate

# app.config["SECRET_KEY"] = SECRET_KEY
app = Flask(__name__)
CORS(app)
# Enter your database connection details below
# app.config['MYSQL_HOST'] = CLOUD_SQL_HOST
app.config["MYSQL_USER"] = CLOUD_SQL_USERNAME
app.config["MYSQL_PASSWORD"] = CLOUD_SQL_PASSWORD
app.config["MYSQL_DB"] = CLOUD_SQL_DATABASE_NAME
app.config["MYSQL_CONNECTION_NAME"] = CLOUD_SQL_CONNECTION_NAME
app.config["SQLALCHEMY_DATABASE_URI"] = SQLALCHEMY_DATABASE_URI
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False

db = SQLAlchemy(app)

# db migrations
# db.init_app(app)
migrate = Migrate(app,db)

# db = sqlalchemy.create_engine(SQLALCHEMY_DATABASE_URI)
login_manager = LoginManager()
login_manager.init_app(app)
Binary file added c_buildr/cloud_sql_proxy
Binary file not shown.
Binary file added c_buildr/cloud_sql_proxy.exe
Binary file not shown.
33 changes: 33 additions & 0 deletions c_buildr/config_github.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import os
from dotenv import load_dotenv

basedir = os.path.abspath(os.path.dirname(__file__))
load_dotenv(os.path.join(basedir, ".flaskenv"))

# Uncomment line below for a new 16 character secret key everytime you launch your web app
# SECRET_KEY = ''.join(random.choices(string.ascii_letters + string.digits,k=16))

SECRET_KEY = "ANY RANDOM LETTERS YOU CHOOSE TO USE"
# print(SECRET_KEY)

# DB details based on Google Cloud MySQL Auth Proxy Setup
CLOUD_SQL_USERNAME = ""
CLOUD_SQL_PASSWORD = ""
CLOUD_SQL_DATABASE_NAME = ""
CLOUD_SQL_CONNECTION_NAME = ""

# when deploying, be sure to change .flaskenv variable 'FLASK_ENV' to 'production'
if os.environ.get("FLASK_ENV") == "production":
SQLALCHEMY_DATABASE_URI = f"mysql+pymysql://{CLOUD_SQL_USERNAME}:{CLOUD_SQL_PASSWORD}@/{CLOUD_SQL_DATABASE_NAME}?unix_socket=/cloudsql/{CLOUD_SQL_CONNECTION_NAME}"
else:
SQLALCHEMY_DATABASE_URI = f"mysql+pymysql://{CLOUD_SQL_USERNAME}:{CLOUD_SQL_PASSWORD}@127.0.0.1:3306/{CLOUD_SQL_DATABASE_NAME}"
SQLALCHEMY_ECHO = False


# twilio auth details for messaging function
ACCOUNT_SID = ""
AUTH_TOKEN = ""

# stripe integration details, use test keys unless running in production/live mode
STRIPE_PUBLISHABLE_KEY_TEST = ""
STRIPE_SECRET_KEY_TEST = ""
11 changes: 11 additions & 0 deletions c_buildr/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from flask_wtf import Form
from wtforms import StringField, PasswordField, TextField
from wtforms.validators import DataRequired, Email


class EmailForm(Form):
email = StringField("Email", validators=[DataRequired(), Email()])


class PasswordForm(Form):
password = PasswordField("Email", validators=[DataRequired()])
Loading

0 comments on commit 1cc443b

Please sign in to comment.