Final touches before deployment, celery installed

This commit is contained in:
matteo-id committed 2022-06-08 21:38:34 -04:00
1 parent 544f5324e0
commit a2e9d8f879
1212 files changed
+133115 -74

No files matched your search

Binary file not shown.
+7
View File
@@ -0,0 +1,7 @@
from __future__ import absolute_import, unicode_literals
# This will make sure the app is always imported when
# Django starts so that shared_task will use this app.
from .celery import app as celery_app
__all__ = ('celery_app',)
+3
View File
@@ -4,3 +4,6 @@ from django.apps import AppConfig
class LottopyConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'lottopy'
def ready(self):
# Initialize celery
import lottopy.celery
+21
View File
@@ -0,0 +1,21 @@
import os
from celery import Celery
# Set the default Django settings module for the 'celery' program.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'lottopy.settings')
app = Celery('lottopy')
# Using a string here means the worker doesn't have to serialize
# the configuration object to child processes.
# - namespace='CELERY' means all celery-related configuration keys
# should have a `CELERY_` prefix.
app.config_from_object('django.conf:settings', namespace='CELERY')
# Load task modules from all registered Django apps.
app.autodiscover_tasks()
#@app.task(bind=True)
#def debug_task(self):
# print(f'Request: {self.request!r}')
@@ -1,2 +1,2 @@
Winning_Numbers,Chance
14-18-22-23-5-9,347/177100
14-18-2-22-5-9,49/25300
1 Winning_Numbers Chance
2 14-18-22-23-5-9 14-18-2-22-5-9 347/177100 49/25300
Binary file not shown.
@@ -1,2 +1,2 @@
Winning_Numbers,Chance
0-3-6,17/5000
0-8-9,2/625
1 Winning_Numbers Chance
2 0-3-6 0-8-9 17/5000 2/625
@@ -1,2 +1,2 @@
Winning_Numbers,Chance
3-5-6-8,267/5000
3-5-7-8,67/1250
1 Winning_Numbers Chance
2 3-5-6-8 3-5-7-8 267/5000 67/1250
Binary file not shown.
Binary file not shown.
@@ -1,2 +1,2 @@
Winning_Numbers,SB,Chance
1-10-32-49-8,[3],1/270725
1-10-32-46-8,[9],1/265200
1 Winning_Numbers SB Chance
2 1-10-32-49-8 1-10-32-46-8 [3] [9] 1/270725 1/265200
Binary file not shown.
@@ -1,2 +1,2 @@
Winning_Numbers,MB,Chance
17-26-40-52-7,[24],1/4034338
17-26-40-52-7,[24],38/151287675
1 Winning_Numbers MB Chance
2 17-26-40-52-7 [24] 1/4034338 38/151287675
@@ -1,2 +1,2 @@
Winning_Numbers,PB,Chance
21-33-39-59-63,[17],16/48700223
21-39-59-61-63,[17],3/8854586
1 Winning_Numbers PB Chance
2 21-33-39-59-63 21-39-59-61-63 [17] 16/48700223 3/8854586
+13
View File
@@ -1,3 +1,16 @@
from django.db import models
import os, csv
# Create your models here.
class Lotto():
module_dir = os.path.dirname(__file__)
names = list(["pb", "mm", "la", "d3", "d4", "c25"])
files = list()
for i in names:
files.append(os.path.join(module_dir,"lottopy_web_edition",i+"_ans.csv"))
files = [i for i in files if os.path.isfile(i)]
def get_ans(f):
ans = csv.DictReader(open(f), delimiter=',')
fmt = [str(k)[1:-1].replace("'"," ").replace("_"," ") for k in ans]
return str(fmt).replace(",","\n").replace("[","").replace("]","").replace("'","")
+14
View File
@@ -0,0 +1,14 @@
from django.contrib import sitemaps
from django.urls import reverse, path
from .views import home, about, robots_txt
class StaticViewSitemap(sitemaps.Sitemap):
protocol = 'http'
priority=.5,
changefreq='weekly'
def items(self):
return ['home', 'about', 'robots_txt']
def location(self, item):
return reverse(item)
+30
View File
@@ -0,0 +1,30 @@
import os, csv
from celery import shared_task
@shared_task()
def secret():
string = "If you can see this, fuck off"
return string
module_dir = os.path.dirname(__file__)
def get_ans(f):
ans = csv.DictReader(open(f), delimiter=',')
fmt = [str(k)[1:-1].replace("'"," ").replace("_"," ") for k in ans]
return str(fmt).replace(",","\n").replace("[","").replace("]","").replace("'","")
all_nums = []
@shared_task()
class data_task():
def __init__():
pb_file_path = os.path.join(module_dir,'lottopy_web_edition/pb_ans.csv')
mm_file_path = os.path.join(module_dir,'lottopy_web_edition/mm_ans.csv')
la_file_path = os.path.join(module_dir,'lottopy_web_edition/la_ans.csv')
d3_file_path = os.path.join(module_dir,'lottopy_web_edition/d3_ans.csv')
d4_file_path = os.path.join(module_dir,'lottopy_web_edition/d4_ans.csv')
c25_file_path = os.path.join(module_dir,'lottopy_web_edition/c25_ans.csv')
data_task.all_nums.append(pb_file_path, mm_file_path, la_file_path, d3_file_path, d4_file_path, c25_file_path)
return get_ans(all_nums)
#return pbnumbers, mmnumbers, lanumbers, d3numbers, d4numbers, c25numbers
+1 -1
View File
@@ -1,5 +1,5 @@
from django.urls import path
from . import views
from lottopy import views
from django.views.generic.base import TemplateView
urlpatterns = [
+27 -59
View File
@@ -1,84 +1,52 @@
# Create your views here.
from django.http import HttpResponse
from django.views.decorators.http import require_GET
from django.shortcuts import render
from django.conf import settings
from django.core.cache.backends.base import DEFAULT_TIMEOUT
from django.views.decorators.cache import cache_page
import os
import csv
from .models import Lotto
#f = "~/projects/django_lottopy/lottopy_site/lottopy/lottopy_web_edititon/pb_ans.csv"
# MAKE SURE TO START REDIS BEFORE SITE LOADS
CACHE_TTL = getattr(settings, 'CACHE_TTL', DEFAULT_TIMEOUT)
@cache_page(CACHE_TTL)
def base(request):
return render(request, 'lottopy/base.html',
{'nbar': 'home'})
CACHE_TTL = getattr(settings, 'CACHE_TTL', DEFAULT_TIMEOUT)
@cache_page(CACHE_TTL)
def home(request):
# Powerball
module_dir = os.path.dirname(__file__)
pb_file_path = os.path.join(module_dir,'lottopy_web_edition/pb_ans.csv')
pb = csv.DictReader(open(pb_file_path), delimiter=',')
pb_numbers = {}
for x in pb:
pbnumbers = str(x)[1:-1].replace("'"," ").replace(",","\n").replace("_"," ")
pbnumbers.capitalize()
def home(request):
# MegaMil
mm_file_path = os.path.join(module_dir,'lottopy_web_edition/mm_ans.csv')
mm = csv.DictReader(open(mm_file_path), delimiter=',')
mmnumbers = {}
for y in mm:
mmnumbers = str(y)[1:-1].replace("'"," ").replace(",","\n").replace("_"," ")
# Lotto America
la_file_path = os.path.join(module_dir,'lottopy_web_edition/la_ans.csv')
la = csv.DictReader(open(la_file_path), delimiter=',')
lanumbers = {}
for z in la:
lanumbers = str(z)[1:-1].replace("'"," ").replace(",","\n").replace("_"," ")
# Daily3
d3_file_path = os.path.join(module_dir,'lottopy_web_edition/d3_ans.csv')
d3 = csv.DictReader(open(d3_file_path), delimiter=',')
d3numbers = {}
for a in d3:
d3numbers = str(a)[1:-1].replace("'"," ").replace('"', " ").replace(",","\n").replace("_"," ")
# Daily4
d4_file_path = os.path.join(module_dir,'lottopy_web_edition/d4_ans.csv')
d4 = csv.DictReader(open(d4_file_path), delimiter=',')
d4numbers = {}
for b in d4:
d4numbers = str(b)[1:-1].replace("'"," ").replace('"', " ").replace(",","\n").replace("_"," ")
# Cash25
c25_file_path = os.path.join(module_dir,'lottopy_web_edition/c25_ans.csv')
c25 = csv.DictReader(open(c25_file_path), delimiter=',')
c25numbers = {}
for c in c25:
c25numbers = str(c)[1:-1].replace("'"," ").replace('"', " ").replace(",","\n").replace("_"," ")
#Sanitizer (WIP)
#for key, value in pbnumbers.items():
# pbnumbers = str(key)+":"+value
context = {
'nbar': 'home',
'pbnumbers': pbnumbers,
'mmnumbers': mmnumbers,
'lanumbers': lanumbers,
'd3numbers': d3numbers,
'd4numbers': d4numbers,
'c25numbers': c25numbers,
'active': 'active'
'pbnumbers': Lotto.get_ans(Lotto.files[0]),
'mmnumbers': Lotto.get_ans(Lotto.files[1]),
'lanumbers': Lotto.get_ans(Lotto.files[2]),
'd3numbers': Lotto.get_ans(Lotto.files[3]),
'd4numbers': Lotto.get_ans(Lotto.files[4]),
'c25numbers': Lotto.get_ans(Lotto.files[5]),
}
return render(request, 'lottopy/home.html', context)
@cache_page(CACHE_TTL)
def about(request):
return render(request, 'lottopy/about.html',
{'nbar': 'about', 'title': 'About'})
@cache_page(CACHE_TTL)
@require_GET
def robots_txt(require_GET):
lines = [
"User-Agent: *",
"Disallow: /private/",
"Disallow: /junk/",
]
return HttpResponse("\n".join(lines), content_type="text/plain")
def sitemap(request):
return render(request,sitemaps,section=None,template_name='sitemap.xml',content_type='application/xml',)
Whitespace-only changes.
+11 -3
View File
@@ -16,19 +16,17 @@ import os
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-p4+um@+npnfqv=mul^--gz@$36@&7^)h@o*72&yqd@n00x$%e&'
SECRET_KEY = 'w=76&jm5z(xwiz#pk%%7^9e8-@tcwugm*5t#9w#7$ym^3nq%3a'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = ['*']
# Application definition
INSTALLED_APPS = [
@@ -40,8 +38,12 @@ INSTALLED_APPS = [
'django.contrib.messages',
'django.contrib.staticfiles',
'fontawesomefree',
'django.contrib.sites',
'django.contrib.sitemaps',
]
SITE_ID = 1
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
@@ -151,3 +153,9 @@ CACHES = {
}
}
CACHE_TTL = 60 * 60 * 24
CELERY_BROKER_URL = 'redis://localhost:6379/0'
CELERY_RESULT_BACKEND = "redis://localhost:6379/1"
CELERY_TIMEZONE = "America/Eastern"
CELERY_TASK_TRACK_STARTED = True
#CELERY_TASK_TIME_LIMIT = 30 * 60
+8
View File
@@ -15,8 +15,16 @@ Including another URLconf
"""
from django.contrib import admin
from django.urls import include, path
from django.contrib.sitemaps.views import sitemap
from lottopy.sitemaps import StaticViewSitemap
from lottopy import views
sitemaps = {
'static': StaticViewSitemap,
}
urlpatterns = [
path('', include('lottopy.urls')),
path('admin/', admin.site.urls),
path('sitemap.xml', sitemap, {'sitemaps': sitemaps}, name='django.contrib.sitemaps.views.sitemap'),
]
+11 -1
View File
@@ -55,7 +55,7 @@
--bs-body-bg-rgb: 255, 255, 255;
--bs-font-sans-serif: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
--bs-font-monospace: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
--bs-gradient: linear-gradient(180deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0));
--bs-gradient: linear-gradient(180deg, rgba(25, 96, 248, 0.15), rgba(255, 255, 255, 0));
--bs-body-font-family: var(--bs-font-sans-serif);
--bs-body-font-size: 1rem;
--bs-body-font-weight: 400;
@@ -665,6 +665,15 @@ progress {
max-width: 1320px;
}
}
.container-mid {
float: center;
margin-left: auto;
margin-right: auto;
vertical-align: middle;
position: relative;
}
.row {
--bs-gutter-x: 1.5rem;
--bs-gutter-y: 0;
@@ -4539,6 +4548,7 @@ textarea.form-control-lg {
.card > .card-header + .list-group,
.card > .list-group + .card-footer {
border-top: 0;
text-align: bottom;
}
.card-body {
+2 -1
View File
@@ -5,7 +5,8 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width;" />
<!-- <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> -->
<meta name="description" content="A site to predict winning West Virginia Lottery numbers" />
<meta name="description" property="og:description" content="A site created to predict winning West Virginia Lottery numbers" />
<meta name="keywords" content="West Virginia, Lottery, Predictions, Numbers, Winning, how, to, win, thw, lottery, free, generator, edge, best" />
<meta name="author" content="Matteo DiBiagio" />
{% if title %}
<title>WV Lottopy | {{title}}</title>
+3 -3
View File
@@ -62,14 +62,14 @@
</i>
</div>
</div>
<div class="col-lg-4 mb-5 mb-lg-0" style="margin:auto">
<div class="col-lg-4 mb-5 mb-lg-0 container-mid">
<div class="feature bg-primary bg-gradient text-white rounded-3 mb-3">
<h2 class="col-auto mf-box" width=200>Cash Pop coming soon!</h2>
<h2 class="col-auto">Cash Pop coming soon!</h2>
<p>Cash Pop is a new game from the WV lottery, if anyone would like to send support to get it done faster check the About page for more info on how to help!</p>
</div>
</div>
</content>
</div>
</section>
<h6 class="card-footer bg-light" text-align=bottom>Disclaimer: WV Lottopy developers do not guarantee a win on the first or even the fortieth set of numbers. This is used to gain an <b><i>edge </i></b> over those who do not use this program.</h6>
<h6 class="card-footer bg-light">Disclaimer: WV Lottopy developers do not guarantee a win on the first or even the fortieth set of numbers. This is used to gain an <b><i>edge </i></b> over those who do not use this program.</h6>
{% endblock content %}