From 5f3788adafb5173b4f4620d7c1ef26c35baceb5a Mon Sep 17 00:00:00 2001 From: Lakshya Mahajan <68889369+coolcrab28@users.noreply.github.com> Date: Sat, 24 Jun 2023 00:40:39 +0530 Subject: [PATCH 1/8] backend --- author.json | 4 ++-- backend/week1/server.py | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 backend/week1/server.py diff --git a/author.json b/author.json index 3d4a531ce..f6299a591 100644 --- a/author.json +++ b/author.json @@ -1,4 +1,4 @@ { - "name": "", - "entry_number": "" + "name": "Lakshya Mahajan", + "entry_number": "2022CH11429" } diff --git a/backend/week1/server.py b/backend/week1/server.py new file mode 100644 index 000000000..ccc184073 --- /dev/null +++ b/backend/week1/server.py @@ -0,0 +1,17 @@ +import http.server +import json +import urllib.parse + +class URLHandler(http.server.BaseHTTPRequestHandler): + def do_POST(self): + url = urllib.parse.urlparse(self.path) + print(url) + self.send_header("Hello", url) + return +def run_server(): + server_address = ('', 8000) + httpd = http.server.HTTPServer(server_address, URLHandler) + print('Starting server on port 8000...') + httpd.serve_forever() +if __name__ == '__main__': + run_server() \ No newline at end of file From 613fc1747db182736f93ea7d35d6bceddf491962 Mon Sep 17 00:00:00 2001 From: Lakshya Mahajan <68889369+coolcrab28@users.noreply.github.com> Date: Sat, 24 Jun 2023 03:31:07 +0530 Subject: [PATCH 2/8] Fix Backend --- backend/week1/server.py | 48 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 5 deletions(-) diff --git a/backend/week1/server.py b/backend/week1/server.py index ccc184073..58d19e2ce 100644 --- a/backend/week1/server.py +++ b/backend/week1/server.py @@ -1,17 +1,55 @@ import http.server -import json import urllib.parse +url_mappings = {} class URLHandler(http.server.BaseHTTPRequestHandler): + + def do_POST(self): - url = urllib.parse.urlparse(self.path) - print(url) - self.send_header("Hello", url) + url = urllib.parse.urlparse(self.path).path + try: + url_ = url.replace("/create/","") + short, dest = url_.split("/") + url_mappings[short] = (dest, 0) + self.send_response_only(201) + self.send_header("content-type","text") + self.end_headers() + self.wfile.write(bytes(f"mapped {short} to {dest}\n", "utf-8")) + return + except Exception as e: + self.send_response_only(406) + return + + def do_GET(self): + url = urllib.parse.urlparse(self.path).path + url = url.replace("/redirect/", "") + try: + dest = url_mappings[url] + except KeyError: + self.send_response_only(404) + self.send_header("error","Not Found") + self.end_headers() + self.wfile.write(bytes("Error\n", "utf-8")) + return + url_mappings[url] = (dest[0],dest[1]+1) + self.send_response_only(302) + self.send_header("content-type","text/html") + self.end_headers() + self.wfile.write(bytes(f"{dest[0]}\n", "utf-8")) return + + def run_server(): server_address = ('', 8000) httpd = http.server.HTTPServer(server_address, URLHandler) print('Starting server on port 8000...') - httpd.serve_forever() + try: + httpd.serve_forever() + except KeyboardInterrupt: + httpd.server_close() + print("\nexiting....") + exit() + except Exception as e: + print(e) if __name__ == '__main__': run_server() \ No newline at end of file From b05dd20ac4e931a4a6d52fc5570eb65f0152b0bf Mon Sep 17 00:00:00 2001 From: Lakshya Mahajan <68889369+coolcrab28@users.noreply.github.com> Date: Tue, 27 Jun 2023 17:19:09 +0530 Subject: [PATCH 3/8] Start Django project --- .gitignore | 4 + backend/mydjangoproject/db.sqlite3 | Bin 0 -> 131072 bytes backend/mydjangoproject/eCom/__init__.py | 0 backend/mydjangoproject/eCom/admin.py | 3 + backend/mydjangoproject/eCom/apps.py | 6 + .../eCom/migrations/__init__.py | 0 backend/mydjangoproject/eCom/models.py | 3 + backend/mydjangoproject/eCom/tests.py | 3 + backend/mydjangoproject/eCom/urls.py | 7 + backend/mydjangoproject/eCom/views.py | 9 ++ backend/mydjangoproject/manage.py | 22 ++++ .../mydjangoproject/__init__.py | 0 .../mydjangoproject/mydjangoproject/asgi.py | 16 +++ .../mydjangoproject/settings.py | 123 ++++++++++++++++++ .../mydjangoproject/mydjangoproject/urls.py | 23 ++++ .../mydjangoproject/mydjangoproject/wsgi.py | 16 +++ 16 files changed, 235 insertions(+) create mode 100644 .gitignore create mode 100644 backend/mydjangoproject/db.sqlite3 create mode 100644 backend/mydjangoproject/eCom/__init__.py create mode 100644 backend/mydjangoproject/eCom/admin.py create mode 100644 backend/mydjangoproject/eCom/apps.py create mode 100644 backend/mydjangoproject/eCom/migrations/__init__.py create mode 100644 backend/mydjangoproject/eCom/models.py create mode 100644 backend/mydjangoproject/eCom/tests.py create mode 100644 backend/mydjangoproject/eCom/urls.py create mode 100644 backend/mydjangoproject/eCom/views.py create mode 100644 backend/mydjangoproject/manage.py create mode 100644 backend/mydjangoproject/mydjangoproject/__init__.py create mode 100644 backend/mydjangoproject/mydjangoproject/asgi.py create mode 100644 backend/mydjangoproject/mydjangoproject/settings.py create mode 100644 backend/mydjangoproject/mydjangoproject/urls.py create mode 100644 backend/mydjangoproject/mydjangoproject/wsgi.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..9924bc693 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +venv/* +venv +backend/mydjangoproject/eCom/__pycache__/* +backend/mydjangoproject/mydjangoproject/__pycache__/* \ No newline at end of file diff --git a/backend/mydjangoproject/db.sqlite3 b/backend/mydjangoproject/db.sqlite3 new file mode 100644 index 0000000000000000000000000000000000000000..6bdc089cd12dccb7ec45a8832cc3b7b1af490d58 GIT binary patch literal 131072 zcmeI5Yit|Yb;mg(MT(Nh(Zlk%+4X8fuXfGITJcTM+cc}Sxwf*lyq4we3g}`wBu6s6 ze8?o_2LiOE*1IV-ZGompfEH-CC{Un9`=L(+MG~M$Q50>_CM~iB`bg1!+BQIvqD7Jq z=>k3X&XDuqP@)C9Fyy}$JD$h6Xa47R@7$R=_l|V!>ZNi^leg-Ps@js1o(Yd2cwUla zkH_;2{m=gG{G6o~UuT2<6)fxhR-f^_@cO5QnX&joW+RC|44oYN{@8P4e-iv4@V($~ z_`f>5?fXUVw}w6%x*~ke^Ywm?2HoHOv?%~?R@?XIpVZBz-dIjvesKD zBAbtB z##2TVR{1?feLPyk_Y`3v*mRKig^7UlCW*hipLpF9=`O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m8B$uke0pP!|Yi9yDC-cBv@w({<&w?9s6`wivU+rBx+=1@7v z!w%)q0ID%M_8`M}ZluW#A1&OcPRPVDN|#8d9`!ICoz!i7(G~(t!H7JBDHvgU|HE6o zIWF)}reMqkq69=7botl;05TGLye24*df>?< zR4E+~k?7vM9AEPE{6Miw%tapf*6^urU=EyWzj8l^_hT_ObUBB>n+t<(nZ5bd)2#G9IEhm=SmjSnUq#gGfso2jj-%bE&a>eV0X<}=$)a#X#4cj z0ZE~`mRGGUrEA-JHKz(iZCNWgr9E|kG;4*iscA*SPk)Jy5|QZJKlK!!B=ngjYfI=# zbt-zswGDL557hwbg_~Nj#b+q!4_Nw5(b(P4c4!c_GeIWdxL(=Rk$O$ps;Ju$xmi^! z6`G$U@79{-ZJIUGeO8mtUCf_*m0b*0`ycy+9E-B9@CJ=rYD$$Jbk%K|hvIz9b3!va zC^rA;VRcTO)?<3_%&@Yafp^CbG_Y)h%%%>x&7x_4N}^tEMQGnL?`d2LUzlCHb7pOP zt58U9C5l}^J>&2nv$x*P8(b0gmIl>s3tow*)J!3hOqdTD+_y8F6Gk{L z&l|4x-Trf*vpqAOHd&00JNY0w4eaAOHd&@Q4WD{r?exg zf&d7B00@8p2!H?xfB*=900@AWSP|EVF`oMW5j-yxV3 zd>-i}|1&1^Cu6i)t8tIL|9d7LQAltL0w4eaAOHd&00JNY0w4eaAOHd&@K_MA%>Nf3 z3qcS80w4eaAOHd&00JNY0w4eaAOHd&@X!fZ-v1xEZ#V=25C8!X009sH0T2KI5C8!X L009tqJP7!zT= literal 0 HcmV?d00001 diff --git a/backend/mydjangoproject/eCom/__init__.py b/backend/mydjangoproject/eCom/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/backend/mydjangoproject/eCom/admin.py b/backend/mydjangoproject/eCom/admin.py new file mode 100644 index 000000000..8c38f3f3d --- /dev/null +++ b/backend/mydjangoproject/eCom/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/backend/mydjangoproject/eCom/apps.py b/backend/mydjangoproject/eCom/apps.py new file mode 100644 index 000000000..2388c3ca8 --- /dev/null +++ b/backend/mydjangoproject/eCom/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class EcomConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'eCom' diff --git a/backend/mydjangoproject/eCom/migrations/__init__.py b/backend/mydjangoproject/eCom/migrations/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/backend/mydjangoproject/eCom/models.py b/backend/mydjangoproject/eCom/models.py new file mode 100644 index 000000000..71a836239 --- /dev/null +++ b/backend/mydjangoproject/eCom/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/backend/mydjangoproject/eCom/tests.py b/backend/mydjangoproject/eCom/tests.py new file mode 100644 index 000000000..7ce503c2d --- /dev/null +++ b/backend/mydjangoproject/eCom/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/backend/mydjangoproject/eCom/urls.py b/backend/mydjangoproject/eCom/urls.py new file mode 100644 index 000000000..a9d7f56e7 --- /dev/null +++ b/backend/mydjangoproject/eCom/urls.py @@ -0,0 +1,7 @@ +from django.urls import path + +from . import views + +urlpatterns = [ + path("", views.index, name="index"), +] \ No newline at end of file diff --git a/backend/mydjangoproject/eCom/views.py b/backend/mydjangoproject/eCom/views.py new file mode 100644 index 000000000..e9bf22443 --- /dev/null +++ b/backend/mydjangoproject/eCom/views.py @@ -0,0 +1,9 @@ +# from django.shortcuts import render + +# Create your views here. + +from django.http import HttpResponse + + +def index(request): + return HttpResponse("Hello, world.") \ No newline at end of file diff --git a/backend/mydjangoproject/manage.py b/backend/mydjangoproject/manage.py new file mode 100644 index 000000000..62f3e6225 --- /dev/null +++ b/backend/mydjangoproject/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', 'mydjangoproject.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/backend/mydjangoproject/mydjangoproject/__init__.py b/backend/mydjangoproject/mydjangoproject/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/backend/mydjangoproject/mydjangoproject/asgi.py b/backend/mydjangoproject/mydjangoproject/asgi.py new file mode 100644 index 000000000..7e23598f6 --- /dev/null +++ b/backend/mydjangoproject/mydjangoproject/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for mydjangoproject 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', 'mydjangoproject.settings') + +application = get_asgi_application() diff --git a/backend/mydjangoproject/mydjangoproject/settings.py b/backend/mydjangoproject/mydjangoproject/settings.py new file mode 100644 index 000000000..c985c23c4 --- /dev/null +++ b/backend/mydjangoproject/mydjangoproject/settings.py @@ -0,0 +1,123 @@ +""" +Django settings for mydjangoproject project. + +Generated by 'django-admin startproject' using Django 4.2.2. + +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/ +""" + +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.2/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'django-insecure-*kroh#v#zj3z3z2g(1yy%j^$vetg)rpcr6gnh2v7g$#qt2ruy$' + +# 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', +] + +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 = 'mydjangoproject.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + '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 = 'mydjangoproject.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', + } +} + + +# 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 = 'IST' + +USE_I18N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/4.2/howto/static-files/ + +STATIC_URL = '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' diff --git a/backend/mydjangoproject/mydjangoproject/urls.py b/backend/mydjangoproject/mydjangoproject/urls.py new file mode 100644 index 000000000..cd13edf61 --- /dev/null +++ b/backend/mydjangoproject/mydjangoproject/urls.py @@ -0,0 +1,23 @@ +""" +URL configuration for mydjangoproject 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 include,path + +urlpatterns = [ + path('admin/', admin.site.urls), + path('',include("eCom.urls")), +] diff --git a/backend/mydjangoproject/mydjangoproject/wsgi.py b/backend/mydjangoproject/mydjangoproject/wsgi.py new file mode 100644 index 000000000..f2f677db2 --- /dev/null +++ b/backend/mydjangoproject/mydjangoproject/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for mydjangoproject 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', 'mydjangoproject.settings') + +application = get_wsgi_application() From 929fd2533738d679452ba094c8e246d9ef79903e Mon Sep 17 00:00:00 2001 From: Lakshya Mahajan <68889369+coolcrab28@users.noreply.github.com> Date: Sat, 1 Jul 2023 12:55:45 +0530 Subject: [PATCH 4/8] create app --- backend/mydjangoproject/db.sqlite3 | Bin 131072 -> 143360 bytes backend/mydjangoproject/eCom/admin.py | 3 ++- .../eCom/migrations/0001_initial.py | 24 ++++++++++++++++++ ...002_remove_product_id_alter_product__id.py | 23 +++++++++++++++++ .../migrations/0003_rename__id_product_id.py | 18 +++++++++++++ .../__pycache__/0001_initial.cpython-310.pyc | Bin 0 -> 781 bytes ...oduct_id_alter_product__id.cpython-310.pyc | Bin 0 -> 750 bytes ...0003_rename__id_product_id.cpython-310.pyc | Bin 0 -> 603 bytes .../__pycache__/__init__.cpython-310.pyc | Bin 0 -> 195 bytes backend/mydjangoproject/eCom/models.py | 9 ++++++- backend/mydjangoproject/eCom/urls.py | 1 + backend/mydjangoproject/eCom/views.py | 5 ++-- .../mydjangoproject/settings.py | 4 +-- .../mydjangoproject/mydjangoproject/urls.py | 2 +- backend/week1/server.py | 3 +-- 15 files changed, 83 insertions(+), 9 deletions(-) create mode 100644 backend/mydjangoproject/eCom/migrations/0001_initial.py create mode 100644 backend/mydjangoproject/eCom/migrations/0002_remove_product_id_alter_product__id.py create mode 100644 backend/mydjangoproject/eCom/migrations/0003_rename__id_product_id.py create mode 100644 backend/mydjangoproject/eCom/migrations/__pycache__/0001_initial.cpython-310.pyc create mode 100644 backend/mydjangoproject/eCom/migrations/__pycache__/0002_remove_product_id_alter_product__id.cpython-310.pyc create mode 100644 backend/mydjangoproject/eCom/migrations/__pycache__/0003_rename__id_product_id.cpython-310.pyc create mode 100644 backend/mydjangoproject/eCom/migrations/__pycache__/__init__.cpython-310.pyc diff --git a/backend/mydjangoproject/db.sqlite3 b/backend/mydjangoproject/db.sqlite3 index 6bdc089cd12dccb7ec45a8832cc3b7b1af490d58..f998d34afd07a4fc3f9820c8e15a3790f1c0a5d1 100644 GIT binary patch delta 3883 zcmcInU2NOd73L)!>&Kz5-NbboyUVqbv@v2S{E+;i_e=eyrM=ji--=lSc-%YEHmf*|(e*Mnbx-{C7mJn+7__$+kx z(YW8^ZZsTS2irULx!-m-*4Zw}T|e5hgXoDw8f6nTc)O^vLzeaf;$)66J~@k!~0l1 z$TEQ=yYOlUo2xaR-?yie3o}fZ7knZU;zVve+4oZ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nl!$p@*3YkT;v8j9gKRX#L5 zh@!e7ADT@JA|-%RIUh(NglxCaiLq7M9n(xpDwpM49Zg3PE;i`H1H-g?X2rB*6gQX+OcvD5zvhwzNqq1aG z4HceyWc&^=Kh(Bvvl(iXa6V~QyD_z%EvVHIZMJAGy^;Tvi^o)XS ztrT%MK}!mTR6L;!+XxNeEH7e&nt8y`q%txs-N60~p`afnlDK?VRLNLDS$sf-G=zB0 zmYQ-IlYLWYNIu$4yCX4V8A=6j(^RcXw_qJjZZX*=vdv?g#;q*ImwNQ8WFjtAEWI)& zm&^JPvWkj{@J~YJrugBmd--n1zm{hmEnbILp6mWrr494^&Z^~JCN-;;d+qpdS8I0b delta 658 zcmY*WO=uHQ5Pq|7ySv#Woo%*~NU=$@R!a>yz$yXpph*ltqc#mmlc=Xu z!9yZ8btwy8s^Xy@+eP-!3bB`hf~}&53TkduK`#}gpy+N&g}&jz`#xsod-F}PCKQW8 zrKPEr5aKcJ#yK>;ryE+QqmwAec7t?S2Nho0sd+tZR&B6lhHaiA9Oemr#dkQ1c`V}t zyskB+qj*AQX(z;TBbOuTL}nWR8;=>JyaZuJ$bs(a7YmOz;Q3!VmZyA7a@MEud09a)Y{TQHA&KH9oo9rbR{i M)?f`aw)h+W0k0Ci{{R30 diff --git a/backend/mydjangoproject/eCom/admin.py b/backend/mydjangoproject/eCom/admin.py index 8c38f3f3d..c8127a270 100644 --- a/backend/mydjangoproject/eCom/admin.py +++ b/backend/mydjangoproject/eCom/admin.py @@ -1,3 +1,4 @@ from django.contrib import admin - +from .models import Product # Register your models here. +admin.site.register(Product) \ No newline at end of file diff --git a/backend/mydjangoproject/eCom/migrations/0001_initial.py b/backend/mydjangoproject/eCom/migrations/0001_initial.py new file mode 100644 index 000000000..80a2d6a67 --- /dev/null +++ b/backend/mydjangoproject/eCom/migrations/0001_initial.py @@ -0,0 +1,24 @@ +# Generated by Django 4.2.2 on 2023-06-27 12:00 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Product', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('_id', models.UUIDField()), + ('name', models.TextField(max_length=50)), + ('descr', models.TextField(max_length=400)), + ('price', models.IntegerField()), + ], + ), + ] diff --git a/backend/mydjangoproject/eCom/migrations/0002_remove_product_id_alter_product__id.py b/backend/mydjangoproject/eCom/migrations/0002_remove_product_id_alter_product__id.py new file mode 100644 index 000000000..650a97fe7 --- /dev/null +++ b/backend/mydjangoproject/eCom/migrations/0002_remove_product_id_alter_product__id.py @@ -0,0 +1,23 @@ +# Generated by Django 4.2.2 on 2023-06-27 12:06 + +from django.db import migrations, models +import uuid + + +class Migration(migrations.Migration): + + dependencies = [ + ('eCom', '0001_initial'), + ] + + operations = [ + migrations.RemoveField( + model_name='product', + name='id', + ), + migrations.AlterField( + model_name='product', + name='_id', + field=models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False), + ), + ] diff --git a/backend/mydjangoproject/eCom/migrations/0003_rename__id_product_id.py b/backend/mydjangoproject/eCom/migrations/0003_rename__id_product_id.py new file mode 100644 index 000000000..c250ed52e --- /dev/null +++ b/backend/mydjangoproject/eCom/migrations/0003_rename__id_product_id.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.2 on 2023-06-27 12:28 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('eCom', '0002_remove_product_id_alter_product__id'), + ] + + operations = [ + migrations.RenameField( + model_name='product', + old_name='_id', + new_name='id', + ), + ] diff --git a/backend/mydjangoproject/eCom/migrations/__pycache__/0001_initial.cpython-310.pyc b/backend/mydjangoproject/eCom/migrations/__pycache__/0001_initial.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..438a40969a0533edaeee07f93ed599f8118377ac GIT binary patch literal 781 zcmYjPOKTKC5bo}oea!4^%t1VOP*1`h64rPNBGH6Mzy#6cG7L1Gsmg3`=CO9qO4h4h z1D*vzkNz6(ef5;TprF>wt|V1dQD0Y4&#s2UkP*H9@fp4d#(p;7Ciw(*NbEyWz<}qh z;4v>mEI50?K!Ep=frotReehxr{5NdWxuRG$5-u!sW>l@K(zPsTsJ8outQ=e zq>#lNSS*0YUdCb{JJW7c0(;XwaAF@i(7p7}1oW`?HTcHJ>XSEw0K!X7Xwaf)g@zP0 zXri(XtX+zX#}VA37S~;H_`kPf*L!6un5VT98upzy*cO$sNX7$8%0BvgYC(fAbP`(sL z!VD?Sb>16n-_&ry$;rXq$~?x4dTB-nWsMn{B?_wkIG(ybWickT~%QAb!T_!tO}(WyWKBzWJPTZ!ckFU%z~U1HsrgpIkRd$q{+APXG*f z&I+FLLZpKGT;xF-JYx`m{J=mWU&!}CDnYzrgYY|@VFTfk!pyC%O}VOErzipQ>TK$3 z*Uj@dBCk9kOF6Jq0H555$D6=xP(YfocZ3)e^cEUhQ(i2lFU7(XK2Fk$6>w$D#z?p9H+C>Pa z*5^68-rAZ%+l^Y{#>Ev{y3xGDL11H|Z~ZVXoEgmFY|wX+YVTFbB}$P1O^y`zm3q_Y z-1qVs;2KwetEs`t(pxasdx=H)7Ek;&E_ssIXxrEZz8X&^&!6sUvS|#s(Bngwlxw_H z`!ln5Jsl4}J{~{HCd9PLUg%|YvC;QW^@U#ORW_x`tE_5@0`0Jz4ShZwkH!zOb3I)W zsjS!lZJd`R*#f6^=H<+;UNs|O$I7;B)upT?p3pvUvI4crMl$R9fF97K>m@T z;DXEFQu^;rE`LQo+kJ!3#kZ8`)uM8t0e Fe*xjh(J%l2 literal 0 HcmV?d00001 diff --git a/backend/mydjangoproject/eCom/migrations/__pycache__/0003_rename__id_product_id.cpython-310.pyc b/backend/mydjangoproject/eCom/migrations/__pycache__/0003_rename__id_product_id.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e5c5738481ecc4021b1b6fe3b63ba7235618b51c GIT binary patch literal 603 zcmYjP%}yIJ5cbb*SOQ!?;*6>unnO?&Zm2>?NN@oTMZH9pEVDC&4ZG{qPH1xmj=TVG z&k9 zlTjKALjvieBu@)kRCXn-p8c=a5h1}NTZK=(UazkmR`wS4*jbq76J3Bd%b zRfVo=ueuR;`@R02x-|I>^-|RgC~;_Ms}bfC71>Zrz7_GZN4(4@Btn+l?2czn(hM!S zJ`R&HA(Pi66+E8gZ}!^6&xxSbd6QkZY}RW0%LV4v7L^Fu=Q%eA^nsXg`kg5PUrrGV(iAOaaM0yz#qT+9L_QW%06G#UL?G8BP?5yY=FXRDad;?$zz z7@x%K;*82f1>eMs#H_@;nB@GF)Z&=p(%jtCBHjEnT@YW_$iT=rCMhvFJ2fvQCbu#L zs4zXhpeR2pHMt}v)j2;mCO0#^D6u3nKd(3@K0Y%qvm`!Vub}c4hfQvNN@-529mxJ- JCLqDW008}aG_L>v literal 0 HcmV?d00001 diff --git a/backend/mydjangoproject/eCom/models.py b/backend/mydjangoproject/eCom/models.py index 71a836239..5be3fa76c 100644 --- a/backend/mydjangoproject/eCom/models.py +++ b/backend/mydjangoproject/eCom/models.py @@ -1,3 +1,10 @@ from django.db import models - +import uuid # Create your models here. +class Product(models.Model): + id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) + name = models.TextField(max_length=50) + descr = models.TextField(max_length=400) + price = models.IntegerField() + def __str__(self): + return self.name diff --git a/backend/mydjangoproject/eCom/urls.py b/backend/mydjangoproject/eCom/urls.py index a9d7f56e7..779e01cf0 100644 --- a/backend/mydjangoproject/eCom/urls.py +++ b/backend/mydjangoproject/eCom/urls.py @@ -4,4 +4,5 @@ urlpatterns = [ path("", views.index, name="index"), + path("greet/", views.greet, name="greetingsss") ] \ No newline at end of file diff --git a/backend/mydjangoproject/eCom/views.py b/backend/mydjangoproject/eCom/views.py index e9bf22443..1b01caa63 100644 --- a/backend/mydjangoproject/eCom/views.py +++ b/backend/mydjangoproject/eCom/views.py @@ -4,6 +4,7 @@ from django.http import HttpResponse - def index(request): - return HttpResponse("Hello, world.") \ No newline at end of file + return HttpResponse("

Hii

") +def greet(request, name): + return HttpResponse(f"Greetings! {name}") \ No newline at end of file diff --git a/backend/mydjangoproject/mydjangoproject/settings.py b/backend/mydjangoproject/mydjangoproject/settings.py index c985c23c4..86c98072b 100644 --- a/backend/mydjangoproject/mydjangoproject/settings.py +++ b/backend/mydjangoproject/mydjangoproject/settings.py @@ -31,6 +31,7 @@ # Application definition INSTALLED_APPS = [ + 'eCom.apps.EcomConfig', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', @@ -105,8 +106,7 @@ LANGUAGE_CODE = 'en-us' -TIME_ZONE = 'IST' - +TIME_ZONE = 'Asia/Kolkata' USE_I18N = True USE_TZ = True diff --git a/backend/mydjangoproject/mydjangoproject/urls.py b/backend/mydjangoproject/mydjangoproject/urls.py index cd13edf61..6d1b754ac 100644 --- a/backend/mydjangoproject/mydjangoproject/urls.py +++ b/backend/mydjangoproject/mydjangoproject/urls.py @@ -16,7 +16,7 @@ """ from django.contrib import admin from django.urls import include,path - +admin.site.site_header = "Admin Panel" urlpatterns = [ path('admin/', admin.site.urls), path('',include("eCom.urls")), diff --git a/backend/week1/server.py b/backend/week1/server.py index 58d19e2ce..3eb5c1130 100644 --- a/backend/week1/server.py +++ b/backend/week1/server.py @@ -3,8 +3,7 @@ url_mappings = {} class URLHandler(http.server.BaseHTTPRequestHandler): - - +# bacc def do_POST(self): url = urllib.parse.urlparse(self.path).path try: From 5b36e71fb92e61932257c8d98a9680ead2fe56fc Mon Sep 17 00:00:00 2001 From: Lakshya Mahajan <68889369+coolcrab28@users.noreply.github.com> Date: Thu, 13 Jul 2023 17:57:00 +0530 Subject: [PATCH 5/8] Create index.html --- frontend/week1/index.html | 1 + 1 file changed, 1 insertion(+) create mode 100644 frontend/week1/index.html diff --git a/frontend/week1/index.html b/frontend/week1/index.html new file mode 100644 index 000000000..47a950ff8 --- /dev/null +++ b/frontend/week1/index.html @@ -0,0 +1 @@ +hii From d9a7c881cd303aeb736965ff689a7fc448c8a271 Mon Sep 17 00:00:00 2001 From: Lakshya Mahajan <68889369+coolcrab28@users.noreply.github.com> Date: Thu, 13 Jul 2023 17:58:13 +0530 Subject: [PATCH 6/8] Update index.html --- frontend/week1/index.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/frontend/week1/index.html b/frontend/week1/index.html index 47a950ff8..b7a0e2dc2 100644 --- a/frontend/week1/index.html +++ b/frontend/week1/index.html @@ -1 +1,3 @@ -hii + +

Hello

+ From 136e7178a52d786b154ece9430b61e987f5408ce Mon Sep 17 00:00:00 2001 From: Lakshya Mahajan <68889369+coolcrab28@users.noreply.github.com> Date: Thu, 13 Jul 2023 17:59:14 +0530 Subject: [PATCH 7/8] Create index.html --- frontend/week1/web/index.html | 1 + 1 file changed, 1 insertion(+) create mode 100644 frontend/week1/web/index.html diff --git a/frontend/week1/web/index.html b/frontend/week1/web/index.html new file mode 100644 index 000000000..557db03de --- /dev/null +++ b/frontend/week1/web/index.html @@ -0,0 +1 @@ +Hello World From d8bf194ffe85b7885eb99ae7aac3b6857b7f5118 Mon Sep 17 00:00:00 2001 From: Lakshya Mahajan <68889369+coolcrab28@users.noreply.github.com> Date: Fri, 14 Jul 2023 15:21:27 +0530 Subject: [PATCH 8/8] Get all forks and commits when a user clicks on full_name --- frontend/week1/index.html | 3 -- frontend/week1/web/index.html | 1 - frontend/week2/web/index.html | 38 +++++++++++++++++++++ frontend/week2/web/main.js | 63 +++++++++++++++++++++++++++++++++++ 4 files changed, 101 insertions(+), 4 deletions(-) delete mode 100644 frontend/week1/index.html delete mode 100644 frontend/week1/web/index.html create mode 100644 frontend/week2/web/index.html create mode 100644 frontend/week2/web/main.js diff --git a/frontend/week1/index.html b/frontend/week1/index.html deleted file mode 100644 index b7a0e2dc2..000000000 --- a/frontend/week1/index.html +++ /dev/null @@ -1,3 +0,0 @@ - -

Hello

- diff --git a/frontend/week1/web/index.html b/frontend/week1/web/index.html deleted file mode 100644 index 557db03de..000000000 --- a/frontend/week1/web/index.html +++ /dev/null @@ -1 +0,0 @@ -Hello World diff --git a/frontend/week2/web/index.html b/frontend/week2/web/index.html new file mode 100644 index 000000000..0b9772be1 --- /dev/null +++ b/frontend/week2/web/index.html @@ -0,0 +1,38 @@ + + + + + + + + + Document + + +
+

GitHub Forks Dashboard

+
+ +
+
+
+ + + + + \ No newline at end of file diff --git a/frontend/week2/web/main.js b/frontend/week2/web/main.js new file mode 100644 index 000000000..6750e4904 --- /dev/null +++ b/frontend/week2/web/main.js @@ -0,0 +1,63 @@ +const API_BASE_URL = 'https://api.github.com'; +const OWNER = 'devclub-iitd'; +const REPO = 'summer-of-code-2023'; +const TOKEN = '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'; + +const div = document.getElementById("container") +// const url = `${API_BASE_URL}/repos/${OWNER}/${REPO}/forks` +async function getForks(url=`${API_BASE_URL}/repos/${OWNER}/${REPO}/forks`){ + loading(); + const headers = { + + } + let response = await fetch(url, + { + method: "GET", + } + ) + let result = await response.json() + console.log(result) + let links = (response.headers.get('link')) + let urls = links.split(",").map(e => { + return { + url: e.match(/<(.*)>/)[1], + title: e.split(";")[1].trim().match(/"(.*)"/)[1] + } + }) + + clear(); + div.innerHTML += '
    ' + result.forEach(i=>{ + let tag; + tag = `

    + +

    +
    + +
    +

    ` + div.innerHTML += tag + }) + div.innerHTML += "
" + urls.forEach(e => { + let elem = `` + div.innerHTML += elem + }) +} + +async function getUserData(repo_name){ + let url = `${API_BASE_URL}/repos/${repo_name}/commits` + const request = await fetch(url); + let result = await request.json() + console.log(result); +} + +function clear(){ + div.innerHTML = "" +} +function loading(){ + div.classList.replace("d-none", "d-block") + div.innerHTML = "

loading...

" +} \ No newline at end of file