-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cc0521e
commit ea1ffd0
Showing
245 changed files
with
54,431 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
FROM python:3.9 | ||
|
||
WORKDIR /app/backend | ||
|
||
COPY requirements.txt /app/backend | ||
RUN pip install -r requirements.txt | ||
|
||
COPY . /app/backend | ||
|
||
EXPOSE 8000 | ||
|
||
CMD python /app/backend/manage.py runserver 0.0.0.0:8000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
pipeline { | ||
agent any | ||
|
||
stages{ | ||
stage("Clone Code"){ | ||
steps { | ||
echo "Cloning the code" | ||
git url:"https://github.com/LondheShubham153/django-notes-app.git", branch: "main" | ||
} | ||
} | ||
stage("Build"){ | ||
steps { | ||
echo "Building the image" | ||
sh "docker build -t my-note-app ." | ||
} | ||
} | ||
stage("Push to Docker Hub"){ | ||
steps { | ||
echo "Pushing the image to docker hub" | ||
withCredentials([usernamePassword(credentialsId:"dockerHub",passwordVariable:"dockerHubPass",usernameVariable:"dockerHubUser")]){ | ||
sh "docker tag my-note-app ${env.dockerHubUser}/my-note-app:latest" | ||
sh "docker login -u ${env.dockerHubUser} -p ${env.dockerHubPass}" | ||
sh "docker push ${env.dockerHubUser}/my-note-app:latest" | ||
} | ||
} | ||
} | ||
stage("Deploy"){ | ||
steps { | ||
echo "Deploying the container" | ||
sh "docker-compose down && docker-compose up -d" | ||
|
||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,30 @@ | ||
# django-notes-app | ||
# Simple Notes App | ||
This is a simple notes app built with React and Django. | ||
|
||
## Requirements | ||
1. Python 3.9 | ||
2. Node.js | ||
3. React | ||
|
||
## Installation | ||
1. Clone the repository | ||
``` | ||
git clone https://github.com/LondheShubham153/django-notes-app.git | ||
``` | ||
|
||
2. Build the app | ||
``` | ||
docker build -t notes-app . | ||
``` | ||
|
||
3. Run the app | ||
``` | ||
docker run -d -p 8000:8000 notes-app:latest | ||
``` | ||
|
||
## Nginx | ||
|
||
Install Nginx reverse proxy to make this application available | ||
|
||
`sudo apt-get update` | ||
`sudo apt install nginx` |
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from django.contrib import admin | ||
from .models import Note | ||
|
||
# Register your models here. | ||
admin.site.register(Note) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class ApiConfig(AppConfig): | ||
default_auto_field = 'django.db.models.BigAutoField' | ||
name = 'api' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Generated by Django 4.1.5 on 2023-01-20 07:38 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Note', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('body', models.TextField(blank=True, null=True)), | ||
('updated', models.DateTimeField(auto_now=True)), | ||
('created', models.DateTimeField(auto_now_add=True)), | ||
], | ||
), | ||
] |
Empty file.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from django.db import models | ||
|
||
# Create your models here. | ||
|
||
class Note(models.Model): | ||
body = models.TextField(null=True, blank=True) | ||
updated = models.DateTimeField(auto_now=True) | ||
created = models.DateTimeField(auto_now_add=True) | ||
def __str__(self): | ||
return self.body[0:69] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from rest_framework.serializers import ModelSerializer | ||
from .models import Note | ||
|
||
class NoteSerializer(ModelSerializer): | ||
class Meta: | ||
model = Note | ||
fields = '__all__' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.test import TestCase | ||
|
||
# Create your tests here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from django.urls import path | ||
from .views import * | ||
|
||
urlpatterns = [ | ||
path('', getRoutes, name="routes"), | ||
path('notes/', getNotes, name="notes"), | ||
path('notes/<str:pk>/update/', updateNote, name="update-note"), | ||
path('notes/<str:pk>/delete/', deleteNote, name="delete-note"), | ||
path('notes/create/', createNote, name="create-note"), | ||
path('notes/<str:pk>/', getNote, name="note"), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
from django.shortcuts import render | ||
from rest_framework.decorators import api_view | ||
from rest_framework.response import Response | ||
from .serializers import NoteSerializer | ||
from .models import Note | ||
|
||
# Create your views here. | ||
|
||
@api_view(['GET']) | ||
def getRoutes(request): | ||
routes = [ | ||
{ | ||
'Endpoint': '/notes/', | ||
'method': 'GET', | ||
'body': None, | ||
'description': 'Returns an array of notes' | ||
}, | ||
{ | ||
'Endpoint': '/notes/id', | ||
'method': 'GET', | ||
'body': None, | ||
'description': 'Returns a single note object' | ||
}, | ||
{ | ||
'Endpoint': '/notes/create/', | ||
'method': 'POST', | ||
'body': {'body': ""}, | ||
'description': 'Creates new note with data sent in post request' | ||
}, | ||
{ | ||
'Endpoint': '/notes/id/update/', | ||
'method': 'PUT', | ||
'body': {'body': ""}, | ||
'description': 'Creates an existing note with data sent in post request' | ||
}, | ||
{ | ||
'Endpoint': '/notes/id/delete/', | ||
'method': 'DELETE', | ||
'body': None, | ||
'description': 'Deletes and exiting note' | ||
}, | ||
] | ||
return Response(routes) | ||
|
||
@api_view(['GET']) | ||
def getNotes(request): | ||
notes = Note.objects.all().order_by('-created') | ||
serializer = NoteSerializer(notes, many=True) | ||
return Response(serializer.data) | ||
|
||
@api_view(['GET']) | ||
def getNote(request, pk): | ||
note = Note.objects.get(id=pk) | ||
serializer = NoteSerializer(note, many=False) | ||
return Response(serializer.data) | ||
|
||
@api_view(['PUT']) | ||
def updateNote(request, pk): | ||
note = Note.objects.get(id=pk) | ||
serializer = NoteSerializer(instance=note, data=request.data) | ||
if serializer.is_valid(): | ||
serializer.save() | ||
return Response(serializer.data) | ||
|
||
@api_view(['DELETE']) | ||
def deleteNote(request, pk): | ||
note = Note.objects.get(id=pk) | ||
note.delete() | ||
return Response('Note was deleted!') | ||
|
||
@api_view(['POST']) | ||
def createNote(request): | ||
data = request.data | ||
note = Note.objects.create( | ||
body=data['body'] | ||
) | ||
serializer = NoteSerializer(note, many=False) | ||
return Response(serializer.data) |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
version : "3.3" | ||
services : | ||
web : | ||
image : trainwithshubham/my-note-app:latest | ||
ports : | ||
- "8000:8000" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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', 'notesapp.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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
FROM node:8 | ||
|
||
WORKDIR /app/ | ||
COPY . /app/ | ||
|
||
RUN npm install | ||
|
||
EXPOSE 3000 | ||
|
||
CMD ["npm","start"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"files": { | ||
"main.css": "/static/css/main.e7772a38.css", | ||
"main.js": "/static/js/main.08442c14.js", | ||
"index.html": "/index.html", | ||
"static/media/add.svg": "/static/media/add.ebf598626c6f9b2211b0578a435aaa6b.svg", | ||
"static/media/arrow-left.svg": "/static/media/arrow-left.b553318e4fdaed1113efb091889b7f47.svg", | ||
"main.e7772a38.css.map": "/static/css/main.e7772a38.css.map", | ||
"main.08442c14.js.map": "/static/js/main.08442c14.js.map" | ||
}, | ||
"entrypoints": [ | ||
"static/css/main.e7772a38.css", | ||
"static/js/main.08442c14.js" | ||
] | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>TWS Community is Amazing</title><script defer="defer" src="/static/js/main.08442c14.js"></script><link href="/static/css/main.e7772a38.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"short_name": "React App", | ||
"name": "Create React App Sample", | ||
"icons": [ | ||
{ | ||
"src": "favicon.ico", | ||
"sizes": "64x64 32x32 24x24 16x16", | ||
"type": "image/x-icon" | ||
}, | ||
{ | ||
"src": "logo192.png", | ||
"type": "image/png", | ||
"sizes": "192x192" | ||
}, | ||
{ | ||
"src": "logo512.png", | ||
"type": "image/png", | ||
"sizes": "512x512" | ||
} | ||
], | ||
"start_url": ".", | ||
"display": "standalone", | ||
"theme_color": "#000000", | ||
"background_color": "#ffffff" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# https://www.robotstxt.org/robotstxt.html | ||
User-agent: * | ||
Disallow: |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.