Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
shamsiddin808 committed Sep 3, 2024
0 parents commit 9b3aebe
Show file tree
Hide file tree
Showing 710 changed files with 77,969 additions and 0 deletions.
Binary file added .DS_Store
Binary file not shown.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
venv
env
Empty file added KunUz/__init__.py
Empty file.
Binary file added KunUz/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
Binary file added KunUz/__pycache__/__init__.cpython-311.pyc
Binary file not shown.
Binary file added KunUz/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file added KunUz/__pycache__/settings.cpython-310.pyc
Binary file not shown.
Binary file added KunUz/__pycache__/settings.cpython-311.pyc
Binary file not shown.
Binary file added KunUz/__pycache__/settings.cpython-39.pyc
Binary file not shown.
Binary file added KunUz/__pycache__/urls.cpython-310.pyc
Binary file not shown.
Binary file added KunUz/__pycache__/urls.cpython-311.pyc
Binary file not shown.
Binary file added KunUz/__pycache__/urls.cpython-39.pyc
Binary file not shown.
Binary file added KunUz/__pycache__/wsgi.cpython-310.pyc
Binary file not shown.
Binary file added KunUz/__pycache__/wsgi.cpython-311.pyc
Binary file not shown.
Binary file added KunUz/__pycache__/wsgi.cpython-39.pyc
Binary file not shown.
16 changes: 16 additions & 0 deletions KunUz/asgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
ASGI config for KunUz project.
It exposes the ASGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/4.2/howto/deployment/asgi/
"""

import os

from django.core.asgi import get_asgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'KunUz.settings')

application = get_asgi_application()
147 changes: 147 additions & 0 deletions KunUz/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
"""
Django settings for KunUz project.
Generated by 'django-admin startproject' using Django 4.2.5.
For more information on this file, see
https://docs.djangoproject.com/en/4.2/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.2/ref/settings/
"""
import os
from pathlib import Path
from corsheaders.defaults import default_headers
import corsheaders

# 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.2/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-r7cbxm)74_3c$($xnnuhm%ax1fi1q2-^&p%tzf7knt2s7zy*5^'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = ["*"]


# Application definition

INSTALLED_APPS = [
'jazzmin',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'UZBnews',
'corsheaders',
]

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'corsheaders.middleware.CorsMiddleware',
]

ROOT_URLCONF = 'KunUz.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]

WSGI_APPLICATION = 'KunUz.wsgi.application'


# Database
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
CORS_ALLOW_ALL_ORIGINS = True
CORS_ORIGIN_ALLOW_ALL = True

CORS_ALLOW_HEADERS = default_headers + (
'cache-control',
)

CORS_ALLOW_METHODS = [
"DELETE",
"GET",
"OPTIONS",
"PATCH",
"POST",
"PUT",
]

# Password validation
# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]


# Internationalization
# https://docs.djangoproject.com/en/4.2/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.2/howto/static-files/

STATIC_URL = '/static/'
# STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')]

MEDIA_URL = '/images/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'static/')
# Default primary key field type
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
79 changes: 79 additions & 0 deletions KunUz/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# import smtplib
# from email.mime.multipart import MIMEMultipart
# from email.mime.text import MIMEText
#
# from_email = '[email protected]'
# email_password = 'bpwr bjap qyvw chnm'
# to_email = '[email protected]'
# subject = 'sharifjon'
# message = 'mominov'
# msg = MIMEMultipart()
# msg['From'] = from_email
# msg['To'] = to_email
# msg['Subject'] = subject
#
# msg.attach(MIMEText(message, 'plain'))
#
# smtp_server = 'smtp.gmail.com'
# smtp_port = 587
# try:
# server = smtplib.SMTP(smtp_server, smtp_port)
#
# server.starttls()
#
# server.login(from_email, email_password)
#
# server.sendmail(from_email, to_email, msg.as_string())
# print('Email sent successfully!')
#
# except Exception as e:
# print('Email could not be sent. Error:', str(e))
#
# finally:
# server.quit()


# Morse kodlari lug'atini aniqlash
morse_code_dict = {
'A': '.-', 'B': '-...', 'C': '-.-.', 'D': '-..', 'E': '.', 'F': '..-.', 'G': '--.', 'H': '....', 'I': '..',
'J': '.---', 'K': '-.-', 'L': '.-..', 'M': '--', 'N': '-.', 'O': '---', 'P': '.--.', 'Q': '--.-', 'R': '.-.',
'S': '...', 'T': '-', 'U': '..-', 'V': '...-', 'W': '.--', 'X': '-..-', 'Y': '-.--', 'Z': '--..',
'0': '-----', '1': '.----', '2': '..---', '3': '...--', '4': '....-', '5': '.....', '6': '-....', '7': '--...',
'8': '---..', '9': '----.',
' ': ' ', # Bo'sh joy (probel)
}

# Matnni Morse tiliga o'giruvchi funksiya
def text_to_morse(text):
morse_code = []
for char in text.upper():
if char in morse_code_dict:
morse_code.append(morse_code_dict[char])
else:
morse_code.append('?') # Agar belgi lug'atta mavjud bo'lmasa, '?' qo'shamiz
return ' '.join(morse_code)

# Morse kodni matnga o'giruvchi funksiya
def morse_to_text(morse_code):
text = []
morse_code = morse_code.split(' ')
for code in morse_code:
for key, value in morse_code_dict.items():
if code == value:
text.append(key)
break
else:
text.append('?') # Agar Morse kodi belgi bilan mos kelmasa, '?' qo'shamiz
return ''.join(text)

# Matn -> Morse
text = input('Soz yozing: ')
morse = text_to_morse(text)
print(f"Matn: {text}")
print(f"Morse: {morse}")

# Morse -> Matn
# morse_code = "... .- .-.. --- --, -.. ..- -. -.-- --- -!"
# text = morse_to_text(morse_code)
# print(f"Morse: {morse_code}")
# print(f"Matn: {text}")
29 changes: 29 additions & 0 deletions KunUz/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"""
URL configuration for KunUz project.
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/4.2/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include
from . import settings
# UZBnews import views
from django.conf.urls.static import static


urlpatterns = [
path('admin/', admin.site.urls),
path('', include('UZBnews.urls')),

# path('', views.index, name='index'),
] + static(settings.STATIC_URL, document_root=settings.STATICFILES_DIRS)
16 changes: 16 additions & 0 deletions KunUz/wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
WSGI config for KunUz project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/4.2/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'KunUz.settings')

application = get_wsgi_application()
Empty file added UZBnews/__init__.py
Empty file.
Binary file added UZBnews/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
Binary file added UZBnews/__pycache__/__init__.cpython-311.pyc
Binary file not shown.
Binary file added UZBnews/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file added UZBnews/__pycache__/admin.cpython-310.pyc
Binary file not shown.
Binary file added UZBnews/__pycache__/admin.cpython-311.pyc
Binary file not shown.
Binary file added UZBnews/__pycache__/admin.cpython-39.pyc
Binary file not shown.
Binary file added UZBnews/__pycache__/apps.cpython-310.pyc
Binary file not shown.
Binary file added UZBnews/__pycache__/apps.cpython-311.pyc
Binary file not shown.
Binary file added UZBnews/__pycache__/apps.cpython-39.pyc
Binary file not shown.
Binary file added UZBnews/__pycache__/models.cpython-310.pyc
Binary file not shown.
Binary file added UZBnews/__pycache__/models.cpython-311.pyc
Binary file not shown.
Binary file added UZBnews/__pycache__/models.cpython-39.pyc
Binary file not shown.
Binary file added UZBnews/__pycache__/urls.cpython-310.pyc
Binary file not shown.
Binary file added UZBnews/__pycache__/urls.cpython-311.pyc
Binary file not shown.
Binary file added UZBnews/__pycache__/urls.cpython-39.pyc
Binary file not shown.
Binary file added UZBnews/__pycache__/views.cpython-310.pyc
Binary file not shown.
Binary file added UZBnews/__pycache__/views.cpython-311.pyc
Binary file not shown.
Binary file added UZBnews/__pycache__/views.cpython-39.pyc
Binary file not shown.
6 changes: 6 additions & 0 deletions UZBnews/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.contrib import admin
from .models import KunlikNewuz

admin.site.register(KunlikNewuz)

# Register your models here.
6 changes: 6 additions & 0 deletions UZBnews/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class UzbnewsConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'UZBnews'
24 changes: 24 additions & 0 deletions UZBnews/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 4.2.5 on 2024-09-03 13:43

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='KunlikNewuz',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('text', models.TextField(max_length=255)),
('time_create', models.DateTimeField(auto_now_add=True)),
('photo', models.ImageField(upload_to='static/images')),
('autor', models.CharField(max_length=255)),
],
),
]
Empty file added UZBnews/migrations/__init__.py
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
17 changes: 17 additions & 0 deletions UZBnews/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from django.db import models

# create model class


from django.db import models


class KunlikNewuz(models.Model):
text = models.TextField(null=False, max_length=255) # Removed max_length for TextField
time_create = models.DateTimeField(auto_now_add=True) # Changed to DateTimeField
photo = models.ImageField(null=False, upload_to='static/images') # Changed to ImageField and corrected upload_to path
autor = models.CharField(max_length=255, null=False) # Added max_length for CharField
def __str__(self):
_ = f"{self.time_create} : {self.autor}"
return _
# Create your models here.
Empty file added UZBnews/serializer.py
Empty file.
Loading

0 comments on commit 9b3aebe

Please sign in to comment.