Skip to content

Commit

Permalink
Add requirements.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmicqbit committed Aug 2, 2023
1 parent cc0521e commit ea1ffd0
Show file tree
Hide file tree
Showing 245 changed files with 54,431 additions and 1 deletion.
12 changes: 12 additions & 0 deletions Dockerfile
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
35 changes: 35 additions & 0 deletions Jenkinsfile
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"

}
}
}
}
31 changes: 30 additions & 1 deletion README.md
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 added api/__init__.py
Empty file.
Binary file added api/__pycache__/__init__.cpython-311.pyc
Binary file not shown.
Binary file added api/__pycache__/admin.cpython-311.pyc
Binary file not shown.
Binary file added api/__pycache__/apps.cpython-311.pyc
Binary file not shown.
Binary file added api/__pycache__/models.cpython-311.pyc
Binary file not shown.
Binary file added api/__pycache__/serializers.cpython-311.pyc
Binary file not shown.
Binary file added api/__pycache__/urls.cpython-311.pyc
Binary file not shown.
Binary file added api/__pycache__/views.cpython-311.pyc
Binary file not shown.
5 changes: 5 additions & 0 deletions api/admin.py
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)
6 changes: 6 additions & 0 deletions api/apps.py
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'
23 changes: 23 additions & 0 deletions api/migrations/0001_initial.py
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 added api/migrations/__init__.py
Empty file.
Binary file not shown.
Binary file added api/migrations/__pycache__/__init__.cpython-311.pyc
Binary file not shown.
10 changes: 10 additions & 0 deletions api/models.py
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]
7 changes: 7 additions & 0 deletions api/serializers.py
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__'
3 changes: 3 additions & 0 deletions api/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
11 changes: 11 additions & 0 deletions api/urls.py
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"),
]
78 changes: 78 additions & 0 deletions api/views.py
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 added db.sqlite3
Binary file not shown.
6 changes: 6 additions & 0 deletions docker-compose.yml
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"
22 changes: 22 additions & 0 deletions manage.py
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()
1 change: 1 addition & 0 deletions mynotes/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
10 changes: 10 additions & 0 deletions mynotes/Dockerfile
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"]
15 changes: 15 additions & 0 deletions mynotes/build/asset-manifest.json
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 added mynotes/build/favicon.ico
Binary file not shown.
1 change: 1 addition & 0 deletions mynotes/build/index.html
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>
Binary file added mynotes/build/logo192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mynotes/build/logo512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions mynotes/build/manifest.json
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"
}
3 changes: 3 additions & 0 deletions mynotes/build/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:
2 changes: 2 additions & 0 deletions mynotes/build/static/css/main.e7772a38.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions mynotes/build/static/css/main.e7772a38.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions mynotes/build/static/js/main.08442c14.js

Large diffs are not rendered by default.

Loading

0 comments on commit ea1ffd0

Please sign in to comment.