From 7ac039871c72ad998ee7f484a057dd1859311f46 Mon Sep 17 00:00:00 2001 From: ashiqurrahmananik Date: Mon, 30 Jan 2023 18:42:05 +0600 Subject: [PATCH] first commit --- UrlShortener/__init__.py | 0 .../__pycache__/__init__.cpython-311.pyc | Bin 0 -> 170 bytes .../__pycache__/settings.cpython-311.pyc | Bin 0 -> 2838 bytes UrlShortener/__pycache__/urls.cpython-311.pyc | Bin 0 -> 1152 bytes UrlShortener/__pycache__/wsgi.cpython-311.pyc | Bin 0 -> 702 bytes UrlShortener/asgi.py | 16 +++ UrlShortener/settings.py | 130 ++++++++++++++++++ UrlShortener/urls.py | 22 +++ UrlShortener/wsgi.py | 16 +++ db.sqlite3 | Bin 0 -> 135168 bytes manage.py | 22 +++ readme.md | 31 +++++ shortener/__init__.py | 0 .../__pycache__/__init__.cpython-311.pyc | Bin 0 -> 167 bytes shortener/__pycache__/admin.cpython-311.pyc | Bin 0 -> 367 bytes shortener/__pycache__/apps.cpython-311.pyc | Bin 0 -> 544 bytes shortener/__pycache__/models.cpython-311.pyc | Bin 0 -> 623 bytes shortener/__pycache__/urls.cpython-311.pyc | Bin 0 -> 530 bytes shortener/__pycache__/views.cpython-311.pyc | Bin 0 -> 1767 bytes shortener/admin.py | 4 + shortener/apps.py | 6 + shortener/migrations/0001_initial.py | 22 +++ shortener/migrations/__init__.py | 0 .../__pycache__/0001_initial.cpython-311.pyc | Bin 0 -> 1006 bytes .../__pycache__/__init__.cpython-311.pyc | Bin 0 -> 178 bytes shortener/models.py | 7 + shortener/tests.py | 3 + shortener/urls.py | 8 ++ shortener/views.py | 22 +++ templates/index.html | 93 +++++++++++++ 30 files changed, 402 insertions(+) create mode 100644 UrlShortener/__init__.py create mode 100644 UrlShortener/__pycache__/__init__.cpython-311.pyc create mode 100644 UrlShortener/__pycache__/settings.cpython-311.pyc create mode 100644 UrlShortener/__pycache__/urls.cpython-311.pyc create mode 100644 UrlShortener/__pycache__/wsgi.cpython-311.pyc create mode 100644 UrlShortener/asgi.py create mode 100644 UrlShortener/settings.py create mode 100644 UrlShortener/urls.py create mode 100644 UrlShortener/wsgi.py create mode 100644 db.sqlite3 create mode 100644 manage.py create mode 100644 readme.md create mode 100644 shortener/__init__.py create mode 100644 shortener/__pycache__/__init__.cpython-311.pyc create mode 100644 shortener/__pycache__/admin.cpython-311.pyc create mode 100644 shortener/__pycache__/apps.cpython-311.pyc create mode 100644 shortener/__pycache__/models.cpython-311.pyc create mode 100644 shortener/__pycache__/urls.cpython-311.pyc create mode 100644 shortener/__pycache__/views.cpython-311.pyc create mode 100644 shortener/admin.py create mode 100644 shortener/apps.py create mode 100644 shortener/migrations/0001_initial.py create mode 100644 shortener/migrations/__init__.py create mode 100644 shortener/migrations/__pycache__/0001_initial.cpython-311.pyc create mode 100644 shortener/migrations/__pycache__/__init__.cpython-311.pyc create mode 100644 shortener/models.py create mode 100644 shortener/tests.py create mode 100644 shortener/urls.py create mode 100644 shortener/views.py create mode 100644 templates/index.html diff --git a/UrlShortener/__init__.py b/UrlShortener/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/UrlShortener/__pycache__/__init__.cpython-311.pyc b/UrlShortener/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..197ed8f9df5ff0fea7b457ef237772beb77cf481 GIT binary patch literal 170 zcmZ3^%ge<81ls-AlR@-j5CH>>P{wCAAY(d13PUi1CZpd Tfy4)9Mn=XD3^1aI87Kw-;HoL4 literal 0 HcmV?d00001 diff --git a/UrlShortener/__pycache__/settings.cpython-311.pyc b/UrlShortener/__pycache__/settings.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a2c1f99b719153d9a7e4f00bccd9c93add2412f9 GIT binary patch literal 2838 zcmb7G&2QUe7=NAbq)D1)S=$XZJe9F!qs~hAfe;Mb#OQQN z%kRzC(+K_HEv8pwGWqLon0$>e5)r0wK&83?F+iaJA^{TofkNnK_>HgcLerW5`2#F| zKHk_5Pp2m{F@l3)6oUidbkP~tq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OZ?=?$L6 z-i0LeRdUz32HLzoS0;wh4N?^41`<@rMc%NCsB;Hs*?+qcl+1j7^Q+hwcfY**``o2p z=Po^+Tlvkqul+W+HjKGxl&(|51OVfyVfZMM9j4qwEE{mqbQq@HTrBNvOa?&bP-bPA zbYm#TQHKlXzPbK%;qpP|jli}iPw{aEN F{s*64wQ&Fd literal 0 HcmV?d00001 diff --git a/UrlShortener/__pycache__/urls.cpython-311.pyc b/UrlShortener/__pycache__/urls.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..2c0c33a8beaeb9c38168cc2d1bfd76c0bbcfd897 GIT binary patch literal 1152 zcma)5&ui2`6rN-!yW1?giXeEBk8BDJe3a$XB-5$@th>uL&85yd{H>Zo1;j4A|lq$2bkzKIo) z8jPA>KT==?zKLCq8>ro;-&jXx)6F1xgNN%w##0(oPBvb@Br7cL2ZM~eX~1G#e>0?H zJL6&ErYYsI*d}2hQo>o5QXvxrNf~(?(09TjtBjL~aY}-?&v;ZokR+t8phQsW=mcz- zripND+h?Az{E-_ESi;$eda32H$fmJ<-&(R$mIR)#Wv~t9g{?n-??!+n9DOy5J;`oT zwg6qS$Wz}ZZcKtG0XYsKea<2h?e^RxDVT zh(0pp+%WZ(&=unD4hZw7Q2)n*r9;Xk5vyoaMdt-z73{CbM#fvN=t+m>%2@3vc#Pz58!2~=5t)9^(A@FA-fm?3VDtFq+(~=>v^{@@5{>$7<=^jGW?Y2z-$zb*pzAnsy=T}x>3#S&qnHf_fU;)~v#yOiEL3@!| zO{gp$|8m|nt92Sm(T#evD^uD^d9yE5jRI4eq;i0vb{(g#DSk|(LPd2S=`l7vTLpd%?d9fP-RsA8ESjf7#1Z!V}520T)< z8*zM06{6GEI#C;*$7HBnHV8yd&NPKG_E31w+;y)n54H3dCR`rHD71H|dXeY+$@6Vg zNcOOY+RxAYIT_i?=Id9D>aO41+S{u)s!jjR?q+Le>$p5$0#~8dk?5&PF)RAM(c$}< zB~^BRs>TgX5^j#2+J-GFq8LW06q#cJ8FqsMuCt{%+8=P0%esEPy|F)q*l)evq5o^X zKhJ*K$ywaw==#o!X{}$TC4*$X5~%lPn%IPpiB%+p3FOlQAkN9%yp3Ufbi0qi`s7?f m`6rY|EAHrN^&Dy!P#ZyQTv{EKR?kao7p1k6rM#v04ESHulhBX= literal 0 HcmV?d00001 diff --git a/UrlShortener/asgi.py b/UrlShortener/asgi.py new file mode 100644 index 0000000..59ca922 --- /dev/null +++ b/UrlShortener/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for UrlShortener 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.1/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'UrlShortener.settings') + +application = get_asgi_application() diff --git a/UrlShortener/settings.py b/UrlShortener/settings.py new file mode 100644 index 0000000..9177519 --- /dev/null +++ b/UrlShortener/settings.py @@ -0,0 +1,130 @@ +""" +Django settings for UrlShortener project. + +Generated by 'django-admin startproject' using Django 4.1.5. + +For more information on this file, see +https://docs.djangoproject.com/en/4.1/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/4.1/ref/settings/ +""" + +from pathlib import Path + +# 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.1/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'django-insecure-yyaa610%yf^hll_hg2mya^u(p7ay7lufy!1f-hi5@p0=hzrh0j' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', + 'shortener' +] + +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', +] + +ROOT_URLCONF = 'UrlShortener.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [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 = 'UrlShortener.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/4.1/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': BASE_DIR / 'db.sqlite3', + } +} + + +# Password validation +# https://docs.djangoproject.com/en/4.1/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', + }, +] +REST_FRAMEWORK = { + 'DEFAULT_AUTHENTICATION_CLASSES': { + 'rest_framework.authentication.BasicAuthentication', + 'rest_framework.authentication.SessionAuthentication', + } + } + + +# Internationalization +# https://docs.djangoproject.com/en/4.1/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.1/howto/static-files/ + +STATIC_URL = 'static/' + +# Default primary key field type +# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field + +DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' diff --git a/UrlShortener/urls.py b/UrlShortener/urls.py new file mode 100644 index 0000000..ed53b8c --- /dev/null +++ b/UrlShortener/urls.py @@ -0,0 +1,22 @@ +"""UrlShortener URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/4.1/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 + +urlpatterns = [ + path('admin/', admin.site.urls), + path('', include('shortener.urls')) +] diff --git a/UrlShortener/wsgi.py b/UrlShortener/wsgi.py new file mode 100644 index 0000000..4192473 --- /dev/null +++ b/UrlShortener/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for UrlShortener 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.1/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'UrlShortener.settings') + +application = get_wsgi_application() diff --git a/db.sqlite3 b/db.sqlite3 new file mode 100644 index 0000000000000000000000000000000000000000..a9a12f5d5f1e21b3b03139c39d0197f1af3e9445 GIT binary patch literal 135168 zcmeI5d2AcmdB8a$#StZuqr+P6`dCr4y=z96GzW)=wwqnrmMyI%*|H^j6?8itk|Sy) z9x@MG-T-Z>^=^vv0Gc)dS|CkPpg>QcX<7uqCTNf%DB7S+QY0==S<^BW!Scim6xhVpiK#Yt>DqR?*5zu3W0^RE%Xk zYpg1;kc>()pW!n~t*GB>6(2o+Z7#Js7g}3hSXrA3Ei7M{dodJlmAa47aOlc%yHYrG zCQKdEv*EL$Fm(_72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4XbJB!C2v01`j~NB{{S0VIF~kN^@u0!W~RfXD4)0;KShVvrOAr06Gwj}(2R zU`gR6MK38lq;Qj>$L;p{{9u&jc3tq~|0Q_d|2X#{?!B;zA0&VTkN^@u0!RP}AOR$R z1dsp{KmthM0T38sJ+AT5=I`La@8ykpJ+2eS%wJ-wnEyZ4>v5evY5p=t_3n;Vu`LgJ zJg%`Z@-qSCCk^~=SPPOh`tANBJ+L}KR;}M57-l@K;0gLOCh(InTCrNbOP>D&{vH=R z`~MF23*4E&_W~aeycW0`IO_kp|4;p8|14DE2MHhnB!C2v01`j~NB{{S0VMEH5QqhQ zuHi|>&-hXT56@vC;};o2X9PatW<_3JKahgwxf*6hYEj_`ZCv?;k zrjwwTkYj_Ep6JjMyXYknk|;~D0ZUJE=t*7l;xaEuu~@&Q7j@`GyXeLEXi^rUKA($= z7+f4`ZCXNdR!mMu#h4fuqkT;+M{w=28CsH%h$UlDwyEU^tvxbBOB8rHDn-3bEk|JO zaT!_y{7k$MkM=gTWP4n4m$-OdPaQYsEThC8m?SD8RnlO|7_HE8ayb0b21y zw5O?+uxll{XvKNxj(n79Y9;Mj$u3%Qj09%;{y*-aIGiyEB!C2v01`j~NB{{S0VIF~ zkN^@u0!W~Z0D1mrxUak54?jo%2_OL^fCP{L5*(X9}uboT+MsoxEDrDl>X9tL;v2RttGvm80VN$WP7m)Ue03*2!tLvZ>#ymCNd8 zK`p99eLF5B)0yOu$5m*Gw<5cvRx_K=-F|jgE{Y51S2bZX@l^F$p_1WcEjh)#sXhH4 DYYra$ literal 0 HcmV?d00001 diff --git a/manage.py b/manage.py new file mode 100644 index 0000000..51af845 --- /dev/null +++ b/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" +import os +import sys + + +def main(): + """Run administrative tasks.""" + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'UrlShortener.settings') + try: + from django.core.management import execute_from_command_line + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc + execute_from_command_line(sys.argv) + + +if __name__ == '__main__': + main() diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..b853f27 --- /dev/null +++ b/readme.md @@ -0,0 +1,31 @@ +## Installation Steps + +### setup python env +python version : 3.11.1 + +### os : windows +### install virtualenv +``` +pip install virtualenv +``` +### create virtualenv +``` +python -m venv venv +``` +### to active virtualenv +``` +.\venv\Scripts\activate +``` +### install requirement packages +``` +pip install -r requirements.txt +``` + +### run project + +``` +python manage.py runserver +``` +### Screen Shots +![1](https://user-images.githubusercontent.com/38730778/215479544-974a2625-9f48-43f9-86b5-3e16b5fd9ddd.JPG) +![2](https://user-images.githubusercontent.com/38730778/215479557-92d82e38-19b2-4902-a87f-c9e3cf8cbad9.JPG) \ No newline at end of file diff --git a/shortener/__init__.py b/shortener/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/shortener/__pycache__/__init__.cpython-311.pyc b/shortener/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..59a3ef5d99a4dd940b0cf83e1c89e2b04aa9bf47 GIT binary patch literal 167 zcmZ3^%ge<81f~7glR@-j5CH>>P{wCAAY(d13PUi1CZpd?h#~=<2Fhd!igMf_b3@HpLj5!Rsj8Tk?3@J=0%sEWC%u&pY z45^G+EHEt#SYa$=I+b}DBLl-~Acg>-ewJVcP1ctnt|sFx*2I+D%)FN%c_5Fuv?#|< zlkFB?N>*ZCdcIzAeqKpYW>OKzIk(ty^HWlDii<$@++r!tEJ?k^QIwjVSzMA@w36X7 zP?X`9xtmoCL~l%JkdH!eMt)IAYF=tlOlVOKf>R6^2HUPzQ2C3)255R|PO4oIFVGy2 zbBbMo#0O?ZM#dWq3Kvk(4F>TGsOSL$YYW$P2H{H#!V{b?GDuuukhlOtMchD>0Of&N AaR2}S literal 0 HcmV?d00001 diff --git a/shortener/__pycache__/apps.cpython-311.pyc b/shortener/__pycache__/apps.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..640a3072ebea3cbce6924ed1b34530fb0edb817e GIT binary patch literal 544 zcmZutze~eF6n>Ya(w{00l@5ZASu%=<2>zfBN(W1q5IAD*S|e!^FU_D+2Y21NI4j~m z)6J6A$*oeSPQFXhis-xK-S_2v`QF`ou2hPE5#7JFA8~(|WFEN;ObrA>V8DnAJz^39 z3Y-8_?trPBJgES$_@-ehOlyLk`;b&8ap52cj(o4N^jLyK3Mm%iw8kBijec7t8nUe`C+h0*gFcSGaQ=^jLVzwU6C#f5OLZ|J!=PpN13 zIHhrsQj|xo#AQmaBiqd?Ym9g7$n8@bO=u@^(PZrfrt*lh?fR~jHnm#kXPb)ySuNrI zkVRk14ua4KZiF0Ok~9Qi4bxz;#3+;OQpoxQ{-y`#Q-1yWr<64N2GIG7WdHyG literal 0 HcmV?d00001 diff --git a/shortener/__pycache__/models.cpython-311.pyc b/shortener/__pycache__/models.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..cecfd79dad87a5965e6b03de940dd3d389e35b06 GIT binary patch literal 623 zcmZutzfS@&6n?!s5IIp2M;x3qpfDO@jEe>rVSue#Jen5MgR

QUT`^O-^rjYN8O#S7c+6SH8K;o?!ZhB&Gg7jclW1B zJ}^^5Gc__(-F>MoChFN#DcD?y7^B?~d{dQlD>ybtP literal 0 HcmV?d00001 diff --git a/shortener/__pycache__/urls.cpython-311.pyc b/shortener/__pycache__/urls.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..57e452ebd24aa9c15e4025788dbeec8386df2689 GIT binary patch literal 530 zcmZ3^%ge<81i@RcCtn28k3k$5V23h3_W>Ex8B!Qh7;_kM8KW2(8B&;1m~)tNnWLB) z8JHMS8Br5CB%g4phSm6G`E~s)iG&h7GQU3tde*a};|D zcQAt{&r6UZO~zX+1&JjYFBu^m*0Rjh^5RK9qmudt}!0ED=Y>OQK<=`Qz90)Twu|>$f9|LMe_qYD?d{M LHwYH-0j&lA#-N4B literal 0 HcmV?d00001 diff --git a/shortener/__pycache__/views.cpython-311.pyc b/shortener/__pycache__/views.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f0df98f383c6ca275a844838b345c123b552ee1f GIT binary patch literal 1767 zcmZux&1>976rYi_lDx7df5a}W3toy{wDCt9a0rypOQ94J++sI9EQYY&8Fts!esrWw zQjm)eDQtqF+Yqo1Iqb=GasGgwO8*3{5o8hUsVCnSeDf)9X1%f%_c3~!dGkJJe)Iku z8%ragt-s$D0tuo2_+m(~7Igj)eg}vkf*n-BIb4x)5=KNKvLjcNoC0%16em?tbE=r9 z9Ic|~beOBpQEr52z|%wrZjg};lue&;$5|;-8Lbk^BAroEX0+g)VZMPQxxpOxjeh5O z^>ymjYgLzWafRG1aFrn`Fp=Rq{|wjx@~-Xqkna)Ha5Ag|L1by|B3*`%&sIua1tKtR z430HMe{N9MbGd`e#l3I8+9ccgYO%KYX#HVkqf}!atx~r6h&fjaHx@rB)2HrA{g)^u zoU<|TqQd7+0^379W1@BM@P5azL&FXf`y8YwQAY{{qK-F^zyb2nHdhfu@Q$c}{p)d! zOY+eXXr9FNVr~;x+PIR@35Tvg~$`9Xf{1~O2a&_lUgwFVx0hSfMj+92DOkkx8Z~%%U z&8bz3Fk$?qWsOL!P_I-YQL4_$RgaB>G?I(dV>+Lyv|6YU8jY0bGg2-BBqQ1N7~{tr zDQ^A=9Y9uPhLC{cJMdb{B*KkItJ0^Bc}%sQXZecja;uCWHY&Uq7|nZ>&BKBpkNXd> zJ=E3A=f57#oN9A{HrLa~n#C99zS%Up*37>D&YC;5=Gxk^)Ug&rYq6>H%!$_g!Q!jM zKbBuFcg##^X5N{%PtDsMb15{Jj@OU#$Lpc_WmE2@$C`x~_P*W3+%0K+b2!n_XG489 z&}Vy-(}%0=d@yNuChc(2ZfafK`hE1}=wR79xwHoNF z{VAkpAYEoc356K>u;4i1-#LFn&=Y_UX*+%|?dul9ZRF#(_yaUbo)&KdR=0V_5tP&u zy#@LS2T?XPxGt@>wGBPZWuJhMaYJ^CZ_9(blj=K>0k`#-P%mG0T$d*emo>O5saRuK z5O53E1_o_peCoAvV7;>1>n*D@ZinOc-h-Yo)p`)#n(r73p|KDs3*tc5vZK-Xpo6Ul zBo-Qw2M-|f01yJm9CwhXaj95>X3KcBkygsPC8xY4Fe$p3fQ(4!FC-#}EHCu?;Hcry zuh|!1$4}RN39K(;jJs$#_`lIb9|g(LMe{*&+|=nS7-#z^W@;MW?W35@Nci(Uy2(VY F?*V&;cq9M- literal 0 HcmV?d00001 diff --git a/shortener/admin.py b/shortener/admin.py new file mode 100644 index 0000000..93a4bdb --- /dev/null +++ b/shortener/admin.py @@ -0,0 +1,4 @@ +from django.contrib import admin +from .models import url +# Register your models here. +admin.site.register(url) diff --git a/shortener/apps.py b/shortener/apps.py new file mode 100644 index 0000000..617df63 --- /dev/null +++ b/shortener/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class ShortenerConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'shortener' diff --git a/shortener/migrations/0001_initial.py b/shortener/migrations/0001_initial.py new file mode 100644 index 0000000..aba90dd --- /dev/null +++ b/shortener/migrations/0001_initial.py @@ -0,0 +1,22 @@ +# Generated by Django 4.1.5 on 2023-01-30 10:18 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='url', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('link', models.CharField(max_length=10000)), + ('uuid', models.CharField(max_length=10)), + ], + ), + ] diff --git a/shortener/migrations/__init__.py b/shortener/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/shortener/migrations/__pycache__/0001_initial.cpython-311.pyc b/shortener/migrations/__pycache__/0001_initial.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e602e271f9677d94a66a3aebbad0936a789747a7 GIT binary patch literal 1006 zcmZuvzfaph6uz?^Cw2k~h!S}yv=UNl21GX~s8UM>q5=je9jr)}n>&nyW2ff?l};Ht zbY!V$|AAB$sOs21p`(!^72Sl?iOmQmroMAXs7l}Yp5Kq}bnkudz6=cL2&D4)S7la0 z=(lislDRf6=D|2X1QG0`8n$pvvLuWow1kNC9ub-1s@yx&2J5izSu#;JkeN9XX;b2Q z&2yR4@WLSCYAqzxk1D;B;-3}+|BG*+4iH5aCdiTqwqzGsiiBvUstTYGA`uxP*=nxq zLj=Q8NajdwD^LdPu53vpndCpFc+cwv2 z8%S>Y6zqa+ziB$Y0E3tH0lJq5eg2 z2iF$19o9AVuuiY%`4wFVLavq@IG8c@eg_@H+C{KdOCC`E=}(5c1n{! zl%Er^Wyb-FOVM#D>Xf3m*f<#~#fJH5v}2gxH)CV&*qG}Wb8&J0@5Fj+%p4mt9b+ag z&L&x9WH8BOHT@icx)dsrwPCgOLM%4ct8)zot#zB9BCk_6Qv$o4+!e4CI}X-WZoWI4 sC+t4B;vGh>KqWH9I8hNcWAyO$m#9UoCg`@>*E_|DbCJ0GPd2^x4+yIVp#T5? literal 0 HcmV?d00001 diff --git a/shortener/migrations/__pycache__/__init__.cpython-311.pyc b/shortener/migrations/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b2b42202d709de4405a02dc73d3a757156670374 GIT binary patch literal 178 zcmZ3^%ge<81f~7glR@-j5CH>>P{wCAAY(d13PUi1CZpd', views.go, name='go') + +] diff --git a/shortener/views.py b/shortener/views.py new file mode 100644 index 0000000..82498ed --- /dev/null +++ b/shortener/views.py @@ -0,0 +1,22 @@ +from django.shortcuts import render, redirect +from .models import url +from django.http import HttpResponse +from hashlib import md5 +# Create your views here. +def index(request): + return render (request,'index.html') + +def create(request): + if request.method == 'POST': + print(request) + url1 = request.POST.get('link1','') + uid = md5(url1.encode()).hexdigest()[:5] + u=str(uid) + print(url1, uid, u) + new_url = url(link=url1, uuid=u) + new_url.save() + params={'shorturl':u,'longurl':url1} + return render(request, 'index.html', params) +def go(request, pk): + url_details=url.objects.get(uuid=pk) + return redirect(url_details.link) diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..13b37d5 --- /dev/null +++ b/templates/index.html @@ -0,0 +1,93 @@ + + + + + + Bootstrap demo + + + + +

+

URL Shortener

+
Enter Your Url Here ↓
+
+ {% csrf_token %} + +
+ +
+
+

http://127.0.0.1:8000/{{shorturl}}

+
+ + + \ No newline at end of file