Skip to content

Commit 21e2024

Browse files
init commit
1 parent a1a9ad8 commit 21e2024

File tree

4,594 files changed

+1842027
-219
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

4,594 files changed

+1842027
-219
lines changed

.dockerignore

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Dockerfile
2+
initial_data/
3+
external notes/
4+
tests/
5+
.github/
6+
.git/
7+
.idea/
8+
*.map
9+
*.docx
10+
*.bat

.gcloudignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/deploy_commands.md
2+
venv/
3+
*.bat
4+
.idea
5+
*.map
6+
*.docx

.gitattributes

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto

.gitignore

+13-128
Original file line numberDiff line numberDiff line change
@@ -1,129 +1,14 @@
1-
# Byte-compiled / optimized / DLL files
2-
__pycache__/
3-
*.py[cod]
4-
*$py.class
5-
6-
# C extensions
7-
*.so
8-
.env.development
9-
# Distribution / packaging
10-
.Python
11-
build/
12-
develop-eggs/
13-
dist/
14-
downloads/
15-
eggs/
16-
.eggs/
17-
lib/
18-
lib64/
19-
parts/
20-
sdist/
21-
var/
22-
wheels/
23-
pip-wheel-metadata/
24-
share/python-wheels/
25-
*.egg-info/
26-
.installed.cfg
27-
*.egg
28-
MANIFEST
29-
30-
# PyInstaller
31-
# Usually these files are written by a python script from a template
32-
# before PyInstaller builds the exe, so as to inject date/other infos into it.
33-
*.manifest
34-
*.spec
35-
36-
# Installer logs
37-
pip-log.txt
38-
pip-delete-this-directory.txt
39-
40-
# Unit test / coverage reports
41-
htmlcov/
42-
.tox/
43-
.nox/
44-
.coverage
45-
.coverage.*
46-
.cache
47-
nosetests.xml
48-
coverage.xml
49-
*.cover
50-
*.py,cover
51-
.hypothesis/
52-
.pytest_cache/
53-
54-
# Translations
55-
*.mo
56-
*.pot
57-
58-
# Django stuff:
59-
*.log
60-
local_settings.py
61-
db.sqlite3
62-
db.sqlite3-journal
63-
64-
# Flask stuff:
65-
instance/
66-
.webassets-cache
67-
68-
# Scrapy stuff:
69-
.scrapy
70-
71-
# Sphinx documentation
72-
docs/_build/
73-
74-
# PyBuilder
75-
target/
76-
77-
# Jupyter Notebook
78-
.ipynb_checkpoints
79-
80-
# IPython
81-
profile_default/
82-
ipython_config.py
83-
84-
# pyenv
85-
.python-version
86-
87-
# pipenv
88-
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
89-
# However, in case of collaboration, if having platform-specific dependencies or dependencies
90-
# having no cross-platform support, pipenv may install dependencies that don't work, or not
91-
# install all needed dependencies.
92-
#Pipfile.lock
93-
94-
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
95-
__pypackages__/
96-
97-
# Celery stuff
98-
celerybeat-schedule
99-
celerybeat.pid
100-
101-
# SageMath parsed files
102-
*.sage.py
103-
104-
# Environments
1+
# Google App Engine generated folder
2+
appengine-generated/
1053
.env
106-
.venv
107-
env/
108-
venv/
109-
ENV/
110-
env.bak/
111-
venv.bak/
112-
113-
# Spyder project settings
114-
.spyderproject
115-
.spyproject
116-
117-
# Rope project settings
118-
.ropeproject
119-
120-
# mkdocs documentation
121-
/site
122-
123-
# mypy
124-
.mypy_cache/
125-
.dmypy.json
126-
dmypy.json
127-
128-
# Pyre type checker
129-
.pyre/
4+
.idea/
5+
deploy_commands.md
6+
*.pyc
7+
*.bat
8+
*.pyo
9+
*.pyd
10+
__pycache__
11+
.pytest_cache
12+
.vscode
13+
*.map
14+
*.docx

Dockerfile

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
# Use the official lightweight Python image.
3+
# https://hub.docker.com/_/python
4+
FROM python:3.9
5+
6+
ENV VIRTUAL_ENV=/opt/venv
7+
RUN python3 -m venv $VIRTUAL_ENV
8+
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
9+
10+
# Allow statements and log messages to immediately appear in the Knative logs
11+
#ENV PYTHONUNBUFFERED True
12+
# We copy just the requirements.txt first to leverage Docker cache
13+
WORKDIR /var/www/app
14+
COPY ./requirements.txt /var/www/app/requirements.txt
15+
RUN pip install -r /var/www/app/requirements.txt
16+
COPY . /var/www/app
17+
ENV PORT 8080
18+
EXPOSE $PORT
19+
# to be equal to the cores available.
20+
CMD exec gunicorn --bind :$PORT run:app --workers 2 --threads 8 --timeout 3600
21+
#ENTRYPOINT ["./gunicorn.sh"]

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2023 MJ-API-Development
3+
Copyright (c) 2021 justice ndou
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
### Cloud Run Trading Admin Application
2+
--
3+
- Created with Python + Flask + Docker
4+
- Deployed on Google Cloud Run
5+
6+
**Development Time**
7+
8+
[![wakatime](https://wakatime.com/badge/github/freelancing-solutions/Flask-admin_app.svg)](https://wakatime.com/badge/github/freelancing-solutions/Flask-admin_app)
9+
10+
***How to Deploy***
11+
12+
gcloud builds submit --tag gcr.io/[projectid]/admin-app
13+
14+

app.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
from flask import Flask
22

33
from src.config.config import config_instance
4-
from src.mail.send_emails import celery
4+
55
from src.main import create_app
66

77

88
app: Flask = create_app(config=config_instance())
99

1010

11+
1112
if __name__ == '__main__':
1213
"""
1314

docker

Whitespace-only changes.

docker-compose.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
version: "3.9" # optional since v1.27.0
2+
services:
3+
web:
4+
container_name: admin-app
5+
build: .
6+
image: mobiusdocker/admin-app:latest
7+
ports:
8+
- 8080:8080
9+
env_file:
10+
- .env
11+
environment:
12+
PORT: ${PORT:-8080}
13+
depends_on:
14+
- rabbit
15+
- memcache
16+
rabbit:
17+
container_name: rabbitmg
18+
image: library/rabbitmq:3
19+
hostname: host-rabbitmq
20+
ports:
21+
- 5672:5672
22+
memcache:
23+
container_name: memcached
24+
image: library/memcached:latest
25+
hostname: host-memcache
26+
ports:
27+
- 11211:11211
28+

gunicorn.sh

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
gunicorn run:app -w 2 --threads 2 -b 0.0.0.0:8080

requirements.txt

-1.63 KB
Binary file not shown.

src/main.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
from flask import Flask, url_for
33
from flask_mail import Mail
44
from src.config import config_instance
5+
6+
57
celery = Celery(main='EOD-MAILER')
68
mail = Mail()
79

@@ -12,15 +14,18 @@ def create_app(config=config_instance()) -> Flask:
1214
:param config:
1315
:return:
1416
"""
15-
app = Flask(__name__, template_folder="../template", static_folder="../static")
17+
app = Flask(__name__, template_folder="template", static_folder="static")
1618

1719
app.config.from_object(config)
1820
with app.app_context():
1921
from src.routes.home import home_route
2022
from src.mail.send_emails import send_mail_route
23+
from src.routes.documentations import docs_route
24+
2125
mail.init_app(app)
2226
celery.config_from_object(config.CELERY_SETTINGS)
2327
app.register_blueprint(home_route)
2428
app.register_blueprint(send_mail_route)
29+
app.register_blueprint(docs_route)
2530

2631
return app

src/routes/documentations.py

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import functools
2+
3+
from flask import Blueprint, render_template, request, jsonify
4+
5+
from src.mail.send_emails import schedule_mail
6+
7+
docs_route = Blueprint('docs', __name__)
8+
9+
10+
@functools.cache
11+
def documentations_routes(path: str) -> dict:
12+
"""
13+
will return a map of paths
14+
:param path:
15+
:return:
16+
"""
17+
_routes = {
18+
'eod': render_template('docs/eod.html', BASE_URL="eod-stock-api.site"),
19+
'exchanges': render_template('docs/exchanges.html', BASE_URL="eod-stock-api.site"),
20+
'fundamentals': render_template('docs/fundamentals.html', BASE_URL="eod-stock-api.site"),
21+
'financial-news': render_template('docs/financial_news.html', BASE_URL="eod-stock-api.site"),
22+
'sentiment': render_template('docs/sentiment.html', BASE_URL="eod-stock-api.site"),
23+
'stocks': render_template('docs/stocks.html', BASE_URL="eod-stock-api.site"),
24+
'options': render_template('docs/options.html', BASE_URL="eod-stock-api.site")
25+
}
26+
return _routes[path]
27+
28+
29+
@docs_route.route('/docs/<string:path>', methods=['GET', 'POST'])
30+
def documentations(path: str):
31+
"""
32+
33+
:param path:
34+
:return:
35+
"""
36+
try:
37+
return documentations_routes(path=path)
38+
except KeyError:
39+
# raise a proper HTTP Error for invalid route
40+
pass
41+

src/routes/home.py

+15
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,21 @@ def home():
1010
return render_template('index.html', BASE_URL="eod-stock-api.site")
1111

1212

13+
@home_route.route('/login')
14+
def login():
15+
return render_template('index.html', BASE_URL="eod-stock-api.site")
16+
17+
18+
@home_route.route('/account')
19+
def account():
20+
return render_template('index.html', BASE_URL="eod-stock-api.site")
21+
22+
23+
@home_route.route('/status')
24+
def status():
25+
return render_template('index.html', BASE_URL="eod-stock-api.site")
26+
27+
1328
@home_route.route('/feedback', methods=['GET', 'POST'])
1429
def form_handler():
1530
"""

0 commit comments

Comments
 (0)