diff --git a/server/python_server/connect.py b/server/python_server/connect.py deleted file mode 100644 index 48c92ee..0000000 --- a/server/python_server/connect.py +++ /dev/null @@ -1,11 +0,0 @@ -import mysql.connector -mydb=mysql.connector.connect(host="localhost",user="root",password="root",database="shoppy") -git=mydb.cursor() - - -mycursor.execute("SELECT * FROM product") - - - -for db in mycursor: - print(db) \ No newline at end of file diff --git a/server/python_server/database/__pycache__/connect.cpython-38.pyc b/server/python_server/database/__pycache__/connect.cpython-38.pyc new file mode 100644 index 0000000..bc7e7b4 Binary files /dev/null and b/server/python_server/database/__pycache__/connect.cpython-38.pyc differ diff --git a/server/python_server/database/connect.py b/server/python_server/database/connect.py new file mode 100644 index 0000000..af1ebd7 --- /dev/null +++ b/server/python_server/database/connect.py @@ -0,0 +1,16 @@ +import os +import mysql.connector +env = os.environ.get("PYTHON_ENV") + +def connectSql(): + if(env =="production"): + mydb=mysql.connector.connect(host="shoppy-db.cexukr3eruop.ap-south-1.rds.amazonaws.com",user="root",password="shoppy_password",database="shoppy") + else: + mydb=mysql.connector.connect(host="localhost",user="root",password="root",database="shoppy") + + return mydb + + + return mycursor + +# mycursor.execute("SELECT * FROM product") diff --git a/server/python_server/pages/__init__.py b/server/python_server/pages/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/server/python_server/pages/__pycache__/__init__.cpython-38.pyc b/server/python_server/pages/__pycache__/__init__.cpython-38.pyc new file mode 100644 index 0000000..91c6b51 Binary files /dev/null and b/server/python_server/pages/__pycache__/__init__.cpython-38.pyc differ diff --git a/server/python_server/pages/__pycache__/admin.cpython-38.pyc b/server/python_server/pages/__pycache__/admin.cpython-38.pyc new file mode 100644 index 0000000..4c6c3d3 Binary files /dev/null and b/server/python_server/pages/__pycache__/admin.cpython-38.pyc differ diff --git a/server/python_server/pages/__pycache__/models.cpython-38.pyc b/server/python_server/pages/__pycache__/models.cpython-38.pyc new file mode 100644 index 0000000..8f5c9e0 Binary files /dev/null and b/server/python_server/pages/__pycache__/models.cpython-38.pyc differ diff --git a/server/python_server/pages/__pycache__/views.cpython-38.pyc b/server/python_server/pages/__pycache__/views.cpython-38.pyc new file mode 100644 index 0000000..fa60c59 Binary files /dev/null and b/server/python_server/pages/__pycache__/views.cpython-38.pyc differ diff --git a/server/python_server/pages/admin.py b/server/python_server/pages/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/server/python_server/pages/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/server/python_server/pages/apps.py b/server/python_server/pages/apps.py new file mode 100644 index 0000000..acdb960 --- /dev/null +++ b/server/python_server/pages/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class PagesConfig(AppConfig): + name = 'pages' diff --git a/server/python_server/pages/migrations/__init__.py b/server/python_server/pages/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/server/python_server/pages/migrations/__pycache__/__init__.cpython-38.pyc b/server/python_server/pages/migrations/__pycache__/__init__.cpython-38.pyc new file mode 100644 index 0000000..f5b005a Binary files /dev/null and b/server/python_server/pages/migrations/__pycache__/__init__.cpython-38.pyc differ diff --git a/server/python_server/pages/models.py b/server/python_server/pages/models.py new file mode 100644 index 0000000..b096caa --- /dev/null +++ b/server/python_server/pages/models.py @@ -0,0 +1,4 @@ +from django.db import models + +# Create your models here. + diff --git a/server/python_server/pages/tests.py b/server/python_server/pages/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/server/python_server/pages/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/server/python_server/pages/views.py b/server/python_server/pages/views.py new file mode 100644 index 0000000..07ded6b --- /dev/null +++ b/server/python_server/pages/views.py @@ -0,0 +1,12 @@ +from django.http import HttpResponse +from django.shortcuts import render +from database import connect + +my = connect.connectSql() +mycursor = my.cursor() +data = mycursor.execute("SELECT * FROM shoppy.product") +print(mycursor) +print(data) +# Create your views here. +def home_view(*args,**kwargs): + return HttpResponse ("

hello world

") diff --git a/server/python_server/python_server/__pycache__/__init__.cpython-38.pyc b/server/python_server/python_server/__pycache__/__init__.cpython-38.pyc index 1ce5ce8..ba50039 100644 Binary files a/server/python_server/python_server/__pycache__/__init__.cpython-38.pyc and b/server/python_server/python_server/__pycache__/__init__.cpython-38.pyc differ diff --git a/server/python_server/python_server/__pycache__/settings.cpython-38.pyc b/server/python_server/python_server/__pycache__/settings.cpython-38.pyc index bae628b..dcd855b 100644 Binary files a/server/python_server/python_server/__pycache__/settings.cpython-38.pyc and b/server/python_server/python_server/__pycache__/settings.cpython-38.pyc differ diff --git a/server/python_server/python_server/__pycache__/urls.cpython-38.pyc b/server/python_server/python_server/__pycache__/urls.cpython-38.pyc index 33d8eae..99e46d1 100644 Binary files a/server/python_server/python_server/__pycache__/urls.cpython-38.pyc and b/server/python_server/python_server/__pycache__/urls.cpython-38.pyc differ diff --git a/server/python_server/python_server/__pycache__/wsgi.cpython-38.pyc b/server/python_server/python_server/__pycache__/wsgi.cpython-38.pyc index a1c4de9..3bff6a1 100644 Binary files a/server/python_server/python_server/__pycache__/wsgi.cpython-38.pyc and b/server/python_server/python_server/__pycache__/wsgi.cpython-38.pyc differ diff --git a/server/python_server/python_server/settings.py b/server/python_server/python_server/settings.py index f67c0a3..55a6fd9 100644 --- a/server/python_server/python_server/settings.py +++ b/server/python_server/python_server/settings.py @@ -37,6 +37,8 @@ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', + + 'pages', ] MIDDLEWARE = [ diff --git a/server/python_server/python_server/urls.py b/server/python_server/python_server/urls.py index 448c699..44221c2 100644 --- a/server/python_server/python_server/urls.py +++ b/server/python_server/python_server/urls.py @@ -15,7 +15,9 @@ """ from django.contrib import admin from django.urls import path +from pages import views urlpatterns = [ + path('',views.home_view,name='home'), path('admin/', admin.site.urls), ]