diff --git a/.replit b/.replit
index e01e257c..077cf633 100644
--- a/.replit
+++ b/.replit
@@ -16,4 +16,9 @@ deploymentTarget = "gce"
[[ports]]
localPort = 3000
+externalPort = 3000
+
+[[ports]]
+localPort = 8000
externalPort = 80
+exposeLocalhost = true
diff --git a/django_project/settings.py b/django_project/settings.py
index 85d47deb..1824a738 100644
--- a/django_project/settings.py
+++ b/django_project/settings.py
@@ -11,6 +11,7 @@
"""
from pathlib import Path
+import os
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
@@ -23,7 +24,7 @@
SECRET_KEY = 'django-insecure-4ju2n@$f9d0c=h)_g0lbb%k9&@rf(xa$d$g$&5ri$uf)*gev^4'
# SECURITY WARNING: don't run with debug turned on in production!
-DEBUG = True
+DEBUG = False
ALLOWED_HOSTS = [".replit.dev", ".replit.app"]
CSRF_TRUSTED_ORIGINS = ["https://*.replit.dev", "https://*.replit.app"]
@@ -37,6 +38,8 @@
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
+ 'myblog',
+ 'weatherapp'
]
MIDDLEWARE = [
@@ -51,7 +54,7 @@
ROOT_URLCONF = 'django_project.urls'
-TEMPLATES = [
+TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [BASE_DIR],
@@ -85,8 +88,8 @@
# https://docs.djangoproject.com/en/5.0/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
- {
- 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
+ {'NAME':'django.contrib.auth.password_validation.UserAttributeSimilarityValidator'
+ ,
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
@@ -117,9 +120,27 @@
STATIC_URL = 'static/'
+'''STATICFILES_DIRS = [
+ BASE_DIR / 'static','''
+
+
+
+STATIC_ROOT = BASE_DIR / 'staticfiles'
+
+
+
STATICFILES_DIRS = [
- BASE_DIR / 'static',
+ BASE_DIR / 'static',
+ BASE_DIR / 'staticweather',
]
+#('myblog', os.path.join(BASE_DIR, 'myblog', 'static')),'''
+
+
+
+STATICFILES_FINDERS = (
+ 'django.contrib.staticfiles.finders.FileSystemFinder',
+ )
+
# Default primary key field type
# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field
diff --git a/django_project/urls.py b/django_project/urls.py
index ece665e5..2eeab0fb 100644
--- a/django_project/urls.py
+++ b/django_project/urls.py
@@ -16,11 +16,18 @@
"""
from django.contrib import admin
from django.urls import path
-
+from django.conf import settings
+from django.conf.urls.static import static
from . import views
+
urlpatterns = [
path('admin/', admin.site.urls),
- path('', views.home, name='home'),
+ path('', views.home, name='home'),
+ #path('weather/',views.weather, name='weather')
]
+
+from weatherapp import views
+urlpatterns += [path('weather/',views.weather, name='weather')]
+
diff --git a/django_project/views.py b/django_project/views.py
index f9042b4c..44791ec2 100644
--- a/django_project/views.py
+++ b/django_project/views.py
@@ -1,5 +1,6 @@
import requests
from django.shortcuts import render
+from weatherapp.views import weather
def home(request):
# USING APIS => Example 1
diff --git a/httpd.conf b/httpd.conf
new file mode 100644
index 00000000..83d31e98
--- /dev/null
+++ b/httpd.conf
@@ -0,0 +1,4 @@
+Alias /static/ /path/to/your/STATIC_ROOT/
+
+ Require all granted
+
\ No newline at end of file
diff --git a/manage.py b/manage.py
old mode 100644
new mode 100755
diff --git a/myblog/__init__.py b/myblog/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/myblog/admin.py b/myblog/admin.py
new file mode 100644
index 00000000..f681ef78
--- /dev/null
+++ b/myblog/admin.py
@@ -0,0 +1,4 @@
+from django.contrib import admin
+from .models import Post
+# Register your models here.
+admin.site.register(Post)
\ No newline at end of file
diff --git a/myblog/apps.py b/myblog/apps.py
new file mode 100644
index 00000000..a5861aa2
--- /dev/null
+++ b/myblog/apps.py
@@ -0,0 +1,6 @@
+from django.apps import AppConfig
+
+
+class MyblogConfig(AppConfig):
+ default_auto_field = 'django.db.models.BigAutoField'
+ name = 'myblog'
diff --git a/myblog/migrations/0001_initial.py b/myblog/migrations/0001_initial.py
new file mode 100644
index 00000000..0ef07951
--- /dev/null
+++ b/myblog/migrations/0001_initial.py
@@ -0,0 +1,38 @@
+# Generated by Django 5.0.2 on 2024-05-13 10:00
+
+import django.db.models.deletion
+import django.utils.timezone
+from django.conf import settings
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ initial = True
+
+ dependencies = [
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='Post',
+ fields=[
+ ('id', models.BigAutoField(auto_created=True, primary_key=True,
+ serialize=False,
+ verbose_name='ID')),
+ ('title', models.CharField(max_length=250)),
+ ('slug', models.SlugField(max_length=250)),
+ ('body', models.TextField()),
+ ('publish', models.DateTimeField(default=django.utils.timezone.now)),
+ ('created', models.DateTimeField(auto_now_add=True)),
+ ('updated', models.DateTimeField(auto_now=True)),
+ ('status', models.CharField(choices=[('DF', 'Draft'),
+ ('PB', 'Published')],
+ default='DF', max_length=2)),
+ ('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
+related_name
+=' blog_posts', to=settings.AUTH_USER_MODEL)),
+ ],
+ ),
+ ]
diff --git a/myblog/migrations/0002_alter_post_author.py b/myblog/migrations/0002_alter_post_author.py
new file mode 100644
index 00000000..323ff85b
--- /dev/null
+++ b/myblog/migrations/0002_alter_post_author.py
@@ -0,0 +1,21 @@
+# Generated by Django 5.0.2 on 2024-05-14 09:22
+
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('myblog', '0001_initial'),
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='post',
+ name='author',
+ field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='blog_posts', to=settings.AUTH_USER_MODEL),
+ ),
+ ]
diff --git a/myblog/migrations/__init__.py b/myblog/migrations/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/myblog/models.py b/myblog/models.py
new file mode 100644
index 00000000..5d3fb39b
--- /dev/null
+++ b/myblog/models.py
@@ -0,0 +1,32 @@
+from django.utils import timezone
+from django.db import models
+from django.contrib.auth.models import User
+
+# Create your models here.
+class Post(models.Model):
+
+ class Status(models.TextChoices):
+ DRAFT = 'DF', 'Draft'
+ PUBLISHED = 'PB', 'Published'
+
+ title = models.CharField(max_length=250)
+ slug = models.SlugField(max_length=250)
+ author = models.ForeignKey(User,
+ on_delete=models.CASCADE,
+ related_name='blog_posts')
+ body = models.TextField()
+ publish = models.DateTimeField(default=timezone.now)
+ created = models.DateTimeField(auto_now_add=True)
+ updated = models.DateTimeField(auto_now=True)
+ status = models.CharField(max_length=2,
+ choices=Status.choices,
+ default=Status.DRAFT)
+
+class Meta:
+ ordering = ['-publish']
+ indexes = [
+ models.Index(fields=['-publish']),
+ ]
+
+def __str__(self):
+ return self.title
diff --git a/myblog/tests.py b/myblog/tests.py
new file mode 100644
index 00000000..7ce503c2
--- /dev/null
+++ b/myblog/tests.py
@@ -0,0 +1,3 @@
+from django.test import TestCase
+
+# Create your tests here.
diff --git a/myblog/views.py b/myblog/views.py
new file mode 100644
index 00000000..91ea44a2
--- /dev/null
+++ b/myblog/views.py
@@ -0,0 +1,3 @@
+from django.shortcuts import render
+
+# Create your views here.
diff --git a/replit.nix b/replit.nix
new file mode 100644
index 00000000..9f20e8c9
--- /dev/null
+++ b/replit.nix
@@ -0,0 +1,5 @@
+{pkgs}: {
+ deps = [
+ pkgs.lsof
+ ];
+}
diff --git a/staticweather/weather.css b/staticweather/weather.css
new file mode 100644
index 00000000..ed40c229
--- /dev/null
+++ b/staticweather/weather.css
@@ -0,0 +1,39 @@
+
+body{
+ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
+ justify-content: center;
+ align-items: center;
+ min-height: 100vh;
+ background-image: linear-gradient(to right, #0f0c29, #302b63, #24243e);
+ background-repeat: no-repeat;
+}
+
+h1{
+ color: #66fcf1;
+ margin-bottom: 50px;
+}
+
+/* .weather-box{
+ background-color: rgba(0, 156, 255, 0.4);
+ padding: 20px;
+ border-radius: 10px;
+ border: none;
+}
+
+.weather-box span{
+ font-size: 15px;
+}
+
+.weather-box h2{
+ margin-top: 10px;
+ margin-bottom: 0;
+}
+
+.weather-box hr{
+ height: 1px;
+ color: #fff;
+ background-color: #fff;
+ border: none;
+ width: 80%;
+ margin-bottom: 20px;
+} */
diff --git a/templates/index.html b/templates/index.html
index b0f60817..cdabd2d2 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -1,4 +1,4 @@
-{% load static%}
+{% load static from static%}
diff --git a/templatesweather/weather.html b/templatesweather/weather.html
new file mode 100644
index 00000000..ecc3e889
--- /dev/null
+++ b/templatesweather/weather.html
@@ -0,0 +1,33 @@
+{% load static from staticweather%}
+
+
+
+
+
+
+
+
+ Document
+
+
+ MY WEATHER TODAY
+
+
+ Today's weather
+{{result3}}
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/weatherapp/__init__.py b/weatherapp/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/weatherapp/admin.py b/weatherapp/admin.py
new file mode 100644
index 00000000..8c38f3f3
--- /dev/null
+++ b/weatherapp/admin.py
@@ -0,0 +1,3 @@
+from django.contrib import admin
+
+# Register your models here.
diff --git a/weatherapp/apps.py b/weatherapp/apps.py
new file mode 100644
index 00000000..19f30c6f
--- /dev/null
+++ b/weatherapp/apps.py
@@ -0,0 +1,13 @@
+from django.apps import AppConfig
+
+
+
+
+class WeatherappConfig(AppConfig):
+ default_auto_field = 'django.db.models.BigAutoField'
+ name = 'weatherapp'
+
+
+def ready(self):
+ from .templates import register_templates
+ register_templatesweather(weather.html)
\ No newline at end of file
diff --git a/weatherapp/migrations/__init__.py b/weatherapp/migrations/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/weatherapp/models.py b/weatherapp/models.py
new file mode 100644
index 00000000..71a83623
--- /dev/null
+++ b/weatherapp/models.py
@@ -0,0 +1,3 @@
+from django.db import models
+
+# Create your models here.
diff --git a/weatherapp/tests.py b/weatherapp/tests.py
new file mode 100644
index 00000000..7ce503c2
--- /dev/null
+++ b/weatherapp/tests.py
@@ -0,0 +1,3 @@
+from django.test import TestCase
+
+# Create your tests here.
diff --git a/weatherapp/urls.py b/weatherapp/urls.py
new file mode 100644
index 00000000..256e16c8
--- /dev/null
+++ b/weatherapp/urls.py
@@ -0,0 +1,12 @@
+
+from django.urls import path
+
+from weatherapp import views
+
+app_name = 'weatherapp'
+
+urlpatterns = [
+ # path('index/', views.index, name='index'),
+ path('', views.weather, name='weather'),
+
+]
\ No newline at end of file
diff --git a/weatherapp/views.py b/weatherapp/views.py
new file mode 100644
index 00000000..a513d3d1
--- /dev/null
+++ b/weatherapp/views.py
@@ -0,0 +1,15 @@
+
+
+import requests
+import json
+from django.shortcuts import render
+
+
+def weather(request):
+ response = requests.get('https://api.openweathermap.org/data/2.5/weather?lat={lat}&lon={lon}&appid=66048f26223dbab85dbd25354dc61f58')
+ data = response.json()
+ result3 = data ['icon']
+
+ return render(request, 'templatesweather/weather.html',{'result3':result3})
+# Create your views here.
+