├── .gitignore
├── README.md
├── assets
├── Screenshot (21).png
├── Screenshot (22).png
├── Screenshot (24).png
├── Screenshot (25).png
├── Screenshot (26).png
├── Screenshot (27).png
├── Screenshot (28).png
├── Screenshot (29).png
├── Screenshot (30).png
├── Screenshot (31).png
└── qgen-final.gif
├── base
├── __init__.py
├── admin.py
├── apps.py
├── decorators.py
├── migrations
│ ├── 0001_initial.py
│ ├── 0002_auto_20210403_1736.py
│ └── __init__.py
├── models.py
├── serializers.py
├── tests.py
├── urls.py
└── views.py
├── manage.py
├── requirements.txt
└── web
├── __init__.py
├── asgi.py
├── settings.py
├── urls.py
└── wsgi.py
/.gitignore:
--------------------------------------------------------------------------------
1 | config.py
2 | credentials.json
3 | db.sqlite3
4 | *.pyc
5 | *.pyo
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
Qgen
2 |
3 | [](https://www.djangoproject.com/)
4 |
5 | [](https://docs.python.org/2/library/sqlite3.html)
6 |
7 | [](https://code.visualstudio.com/ "Visual Studio Code")
8 |
9 |
10 | About
11 |
12 | Many times, we read our notes again and again, without ever getting any information inside our head. Havent you noticed that whenver there is a quiz, or whenever you take a test, you learn the material better? Hence, we have created an app, which used Machine Learning and Natural Language Processing to generate flashcards, quizzes, and summary from your notes! Moreover, we have three types of questions: MCQ, Fill in the blanks, and True or False questions to test you on your notes.
13 | You can also upload handwritten notes to generate quizzes so that you can directly upload a photo and generate a quiz.
14 |
15 |
16 | -----------------------------------
17 |
18 | ### Preview
19 |
20 |
21 |
22 |
23 |
24 | -----------------------------------
25 |
26 |
27 | ### 🚀 Features
28 |
29 |
30 |
31 | - Add/Edit Notes📕
32 | - Based on your notes generate
33 |
34 | - Quiz
35 |
36 | - MCQs 📝
37 | - True/False ✔️ ❎
38 | - Fill in the blanks ❓
39 |
40 | - Summary ✒️
41 | - Flashcards 🔖
42 | - Q/A from images 🚞
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 | -----------------------------------
51 | ### 💻 Tech stack
52 | `Backend` : Django
53 | `Database` : SQLite
54 | `Frontend` : ReactJs, CSS, HTML, Bootstrap, jQuery
55 | `ML`: BERT, Spacy, NLTK
56 |
57 | -----------------------------------
58 |
59 | ### :guide_dog: Installation Guide
60 |
61 | A step by step series of examples that tell you how to get a development env running
62 |
63 | In your cmd:
64 |
65 | ```
66 | git clone https://github.com/Deep-Matrix/qgen-backend
67 | ```
68 |
69 | Then,
70 |
71 | ```
72 | cd qgen-backend
73 | ```
74 |
75 | Create a virtual environment and activate the virtual environment:
76 |
77 | ```
78 | python3 -m venv env
79 | source env/bin/activate
80 | ```
81 |
82 | Install dependencies using the following:
83 |
84 | ```
85 | pip install -r requirements.txt
86 | ```
87 |
88 | Now run the backend using the following:
89 |
90 | ```
91 | python manage.py makemigrations
92 | python manage.py migrate
93 | python manage.py runserver
94 | ```
95 |
96 |
97 | You are done with the setup now!
98 |
99 | ------------------------------------------
100 |
--------------------------------------------------------------------------------
/assets/Screenshot (21).png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Deep-Matrix/qgen-backend/9f5e0c727e9f3b74b96a79a92e0aac34b6056b1a/assets/Screenshot (21).png
--------------------------------------------------------------------------------
/assets/Screenshot (22).png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Deep-Matrix/qgen-backend/9f5e0c727e9f3b74b96a79a92e0aac34b6056b1a/assets/Screenshot (22).png
--------------------------------------------------------------------------------
/assets/Screenshot (24).png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Deep-Matrix/qgen-backend/9f5e0c727e9f3b74b96a79a92e0aac34b6056b1a/assets/Screenshot (24).png
--------------------------------------------------------------------------------
/assets/Screenshot (25).png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Deep-Matrix/qgen-backend/9f5e0c727e9f3b74b96a79a92e0aac34b6056b1a/assets/Screenshot (25).png
--------------------------------------------------------------------------------
/assets/Screenshot (26).png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Deep-Matrix/qgen-backend/9f5e0c727e9f3b74b96a79a92e0aac34b6056b1a/assets/Screenshot (26).png
--------------------------------------------------------------------------------
/assets/Screenshot (27).png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Deep-Matrix/qgen-backend/9f5e0c727e9f3b74b96a79a92e0aac34b6056b1a/assets/Screenshot (27).png
--------------------------------------------------------------------------------
/assets/Screenshot (28).png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Deep-Matrix/qgen-backend/9f5e0c727e9f3b74b96a79a92e0aac34b6056b1a/assets/Screenshot (28).png
--------------------------------------------------------------------------------
/assets/Screenshot (29).png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Deep-Matrix/qgen-backend/9f5e0c727e9f3b74b96a79a92e0aac34b6056b1a/assets/Screenshot (29).png
--------------------------------------------------------------------------------
/assets/Screenshot (30).png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Deep-Matrix/qgen-backend/9f5e0c727e9f3b74b96a79a92e0aac34b6056b1a/assets/Screenshot (30).png
--------------------------------------------------------------------------------
/assets/Screenshot (31).png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Deep-Matrix/qgen-backend/9f5e0c727e9f3b74b96a79a92e0aac34b6056b1a/assets/Screenshot (31).png
--------------------------------------------------------------------------------
/assets/qgen-final.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Deep-Matrix/qgen-backend/9f5e0c727e9f3b74b96a79a92e0aac34b6056b1a/assets/qgen-final.gif
--------------------------------------------------------------------------------
/base/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Deep-Matrix/qgen-backend/9f5e0c727e9f3b74b96a79a92e0aac34b6056b1a/base/__init__.py
--------------------------------------------------------------------------------
/base/admin.py:
--------------------------------------------------------------------------------
1 | from django.contrib import admin
2 | from .models import *
3 | from django.contrib.auth.models import User
4 |
5 | admin.site.register(Notes)
6 |
--------------------------------------------------------------------------------
/base/apps.py:
--------------------------------------------------------------------------------
1 | from django.apps import AppConfig
2 |
3 |
4 | class BaseConfig(AppConfig):
5 | name = 'base'
6 |
--------------------------------------------------------------------------------
/base/decorators.py:
--------------------------------------------------------------------------------
1 | import jwt
2 | from rest_framework.response import Response
3 | from rest_framework import status
4 |
5 |
6 | def get_object_from_token(token,secret_key):
7 | return jwt.decode(token, secret_key, algorithms=["HS256"])
8 |
9 | def get_token_from_object(token,secret_key):
10 | return jwt.encode(token, secret_key, algorithm="HS256")
11 |
12 | def login_required(function):
13 | def wrapper(request, *args, **kw):
14 | try:
15 | if 'Authorization' in request.headers:
16 | obj = get_object_from_token(request.headers['Authorization'], '_SECRET_KEY')
17 | if obj and obj.get('user_id'):
18 | print("Token aya")
19 | return function(request, *args, **kw)
20 | else:
21 | print("Token nahi aya")
22 | return Response({'Error':"Invalid token"},status=status.HTTP_500_INTERNAL_SERVER_ERROR)
23 | except Exception as e:
24 | print("Token is invalid")
25 | return Response({'Error':"Invalid token"},status=status.HTTP_500_INTERNAL_SERVER_ERROR)
26 | return wrapper
--------------------------------------------------------------------------------
/base/migrations/0001_initial.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 3.1.4 on 2021-04-03 09:29
2 |
3 | from django.conf import settings
4 | from django.db import migrations, models
5 | import django.db.models.deletion
6 |
7 |
8 | class Migration(migrations.Migration):
9 |
10 | initial = True
11 |
12 | dependencies = [
13 | migrations.swappable_dependency(settings.AUTH_USER_MODEL),
14 | ]
15 |
16 | operations = [
17 | migrations.CreateModel(
18 | name='Notes',
19 | fields=[
20 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
21 | ('note_title', models.CharField(max_length=50)),
22 | ('content', models.TextField()),
23 | ('doc', models.DateTimeField(auto_now_add=True)),
24 | ('user_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
25 | ],
26 | ),
27 | ]
28 |
--------------------------------------------------------------------------------
/base/migrations/0002_auto_20210403_1736.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 3.1.4 on 2021-04-03 12:06
2 |
3 | from django.db import migrations
4 | import djrichtextfield.models
5 |
6 |
7 | class Migration(migrations.Migration):
8 |
9 | dependencies = [
10 | ('base', '0001_initial'),
11 | ]
12 |
13 | operations = [
14 | migrations.AlterField(
15 | model_name='notes',
16 | name='content',
17 | field=djrichtextfield.models.RichTextField(),
18 | ),
19 | migrations.AlterField(
20 | model_name='notes',
21 | name='note_title',
22 | field=djrichtextfield.models.RichTextField(),
23 | ),
24 | ]
25 |
--------------------------------------------------------------------------------
/base/migrations/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Deep-Matrix/qgen-backend/9f5e0c727e9f3b74b96a79a92e0aac34b6056b1a/base/migrations/__init__.py
--------------------------------------------------------------------------------
/base/models.py:
--------------------------------------------------------------------------------
1 | from django.db import models
2 | from django.contrib.auth.models import User
3 | from djrichtextfield.models import RichTextField
4 |
5 | class Notes(models.Model):
6 | note_title = RichTextField()
7 | content = RichTextField()
8 | user_id = models.ForeignKey(User,on_delete=models.CASCADE)
9 | doc = models.DateTimeField(auto_now_add=True)
10 |
11 |
--------------------------------------------------------------------------------
/base/serializers.py:
--------------------------------------------------------------------------------
1 | from rest_framework import serializers
2 | from .models import Notes
3 | from django.contrib.auth.models import User
4 |
5 | class NoteSerializer(serializers.ModelSerializer):
6 | class Meta:
7 | model = Notes
8 | fields = '__all__'
9 |
10 | class UserSerializer(serializers.ModelSerializer):
11 | class Meta:
12 | model = User
13 | fields = '__all__'
--------------------------------------------------------------------------------
/base/tests.py:
--------------------------------------------------------------------------------
1 | from django.test import TestCase
2 |
3 | # Create your tests here.
4 |
--------------------------------------------------------------------------------
/base/urls.py:
--------------------------------------------------------------------------------
1 | from django.urls import path,include
2 | from . import views
3 | urlpatterns = [
4 | path('login',views.login,name='login'),
5 | path('register',views.register,name='register'),
6 | path('get_notes',views.get_notes,name='get_notes'),
7 | path('put_note',views.put_notes,name='put_notes'),
8 | path('delete_note',views.delete_notes,name='delete_notes'),
9 | path('update_note',views.update_notes,name='update_notes'),
10 | path('get_questions',views.get_questions,name='get_questions'),
11 | path('get_image_content',views.get_image_content,name='get_image_content'),
12 | path('get_summary',views.get_summary,name='get_summary'),
13 | path('get_image_content_summary',views.get_image_content_summary,name='get_image_content_summary'),
14 | path('get_flashcards',views.get_flashcards,name='get_flashcards'),
15 | path('get_image_content_flashcards',views.get_image_content_flashcards,name='get_image_content_flashcards'),
16 | ]
17 |
--------------------------------------------------------------------------------
/base/views.py:
--------------------------------------------------------------------------------
1 | from rest_framework.response import Response
2 | from django.http import HttpResponse, JsonResponse
3 | from rest_framework.decorators import api_view
4 | from rest_framework import status
5 | from django.contrib.auth.models import User
6 | from .models import *
7 | from .serializers import *
8 | from .decorators import *
9 | import jwt
10 | import requests
11 | import json
12 | from django.views.decorators.csrf import csrf_exempt
13 | import base64
14 | from django.utils.html import strip_tags
15 |
16 |
17 | #auth
18 | @api_view(['POST'])
19 | def login(request):
20 | if request.method == 'POST':
21 | json_data = request.data
22 | email_id = json_data['email_id']
23 | password = json_data['password']
24 | # password hash
25 | users = User.objects.filter(email=email_id)
26 | if not users:
27 | return Response({'Message':"No user found in the database"},status=status.HTTP_500_INTERNAL_SERVER_ERROR)
28 | user = users.first()
29 | if not user.password == password:
30 | return Response({'Message':"Wrong password"},status=status.HTTP_500_INTERNAL_SERVER_ERROR)
31 | user_id = user.id
32 | token = get_token_from_object({'user_id':user_id},"_SECRET_KEY")
33 | user_serializer = UserSerializer([user],many=True)
34 | return Response({'Message':"User has been logged in",'user':user_serializer.data,'token':token},status=status.HTTP_200_OK)
35 | else:
36 | return Response({'Message':"Wrong method"},status=status.HTTP_400_BAD_REQUEST)
37 |
38 |
39 | @api_view(['POST'])
40 | def register(request):
41 | if request.method == 'POST':
42 | print("ANDAR AAGAYA")
43 | json_data = request.data
44 | email_id = json_data['email_id']
45 | password = json_data['password']
46 | username = json_data['username']
47 | # hash password
48 | users = User.objects.filter(email=email_id)
49 | if users:
50 | return Response({'Error':"Email already exists"},status=status.HTTP_500_INTERNAL_SERVER_ERROR)
51 | new_user = User(email = email_id,username=username, password = password)
52 | new_user.save()
53 | return Response({'Message':"User has been created"},status=status.HTTP_200_OK)
54 | else:
55 | return Response({'Error':"Wrong method"},status=status.HTTP_400_BAD_REQUEST)
56 |
57 |
58 | #get note
59 | @api_view(['POST'])
60 | @login_required
61 | @csrf_exempt
62 | def get_notes(request):
63 | json_data = request.data
64 | user_id = json_data['user_id']
65 | user = User.objects.get(id = user_id)
66 | notes = Notes.objects.filter(user_id=user)
67 | serializer = NoteSerializer(notes,many=True)
68 | # return JsonResponse(serializer.data,safe=False)
69 | return Response({'Message':"all notes", 'data': serializer.data},status=status.HTTP_200_OK)
70 |
71 | #add note
72 | @api_view(['POST'])
73 | @login_required
74 | @csrf_exempt
75 | def put_notes(request):
76 | if request.method == 'POST':
77 | json_data = request.data
78 | note_title = json_data['note_title']
79 | note_content = json_data['note_content']
80 | user_id = json_data['user_id']
81 | user_object = User.objects.get(id=user_id)
82 | note = Notes(user_id=user_object,note_title=note_title, content = note_content)
83 | note.save()
84 | return Response({'Message':"Note has been created"},status=status.HTTP_200_OK)
85 |
86 | #delete note
87 | @api_view(['POST'])
88 | @login_required
89 | @csrf_exempt
90 | def delete_notes(request):
91 | if request.method == 'POST':
92 | json_data = request.data
93 | note_id = json_data['note_id']
94 | note = Notes(id=note_id).delete()
95 | return Response({'Message':"Note has been deleted"},status=status.HTTP_200_OK)
96 |
97 |
98 |
99 | #update note
100 | @api_view(['POST'])
101 | @login_required
102 | @csrf_exempt
103 | def update_notes(request):
104 | if request.method == 'POST':
105 | json_data = request.data
106 | note_id = json_data['note_id']
107 | note = Notes.objects.get(id = note_id)
108 | note.note_title = json_data['note_title']
109 | note.content = json_data['note_content']
110 | note.save()
111 | return Response({'Message':"Note has been updated"},status=status.HTTP_200_OK)
112 |
113 |
114 | #get questions text from frontend pass to flask server then the questions genereated are passed to frontend again
115 | @api_view(['POST'])
116 | # @login_required
117 | def get_questions(request):
118 | if request.method == 'POST':
119 | print('aaya')
120 | json_data = request.data
121 | note_id = json_data['note_id']
122 | number_of_questions = json_data['number_of_questions']
123 | # [props.showQuizPage.fib, props.showQuizPage.mcq, props.showQuizPage.tf]
124 |
125 | types_of_questions = [json_data['types_of_questions'][0],
126 | json_data['types_of_questions'][1],
127 | json_data['types_of_questions'][2]]
128 |
129 |
130 | note = Notes.objects.get(id = note_id)
131 | print(types_of_questions)
132 | print("aagaya atleast yaha! ")
133 | #url for ml server
134 | ml_server_url = "http://717830fd426d.ngrok.io/questions"
135 | print(note.content)
136 | data = requests.post(ml_server_url, data = {'note_text': strip_tags(note.content), 'number_of_questions': number_of_questions, 'fib' : json_data['types_of_questions'][0], 'mcq' : json_data['types_of_questions'][1], 'tf' : json_data['types_of_questions'][2]})
137 | questions = json.loads(data.text)['questions']
138 | print(questions)
139 | return Response({'Message':"recieved all questions from text", 'data': questions},status=status.HTTP_200_OK)
140 |
141 |
142 | # get note from image, pass to ocr flask server get text,
143 | # send text to question generation flask, send this questions to frontend
144 | @api_view(['POST'])
145 | @login_required
146 | def get_image_content(request):
147 | if request.method == 'POST':
148 | print('aaya image')
149 | json_data = request.data
150 | # number_of_questions = json_data['number_of_questions']
151 | number_of_questions = 7
152 | img_data = request.FILES['file'].read()
153 | # types_of_questions = {"fib": json_data['types_of_questions'][0],
154 | # "mcq" : json_data['types_of_questions'][1],
155 | # "tf" : json_data['types_of_questions'][2]}
156 |
157 | types_of_questions = {"fib": False,
158 | "mcq" : True,
159 | "tf" : True}
160 | # print(img_data)
161 | img_string = base64.b64encode(img_data)
162 |
163 | #url for ml server image to text
164 | ml_server_url = "http://717830fd426d.ngrok.io/ocr"
165 | data = requests.post(ml_server_url, data = {'img_base64': img_string})
166 | note_text = json.loads(data.text)['image_text']
167 | print(note_text)
168 | new_note = strip_tags(note_text[0]['text'])
169 | #url for ml server question generation
170 | ml_server_url = "http://717830fd426d.ngrok.io/questions"
171 | data = requests.post(ml_server_url, data = {'note_text': new_note, 'number_of_questions': number_of_questions, 'fib' : 'False' , 'mcq' : 'True', 'tf' : 'True'})
172 | questions = json.loads(data.text)['questions']
173 | print(json.loads(data.text))
174 | print(questions)
175 | return Response({'Message':"recieved all questions", 'data': questions},status=status.HTTP_200_OK)
176 |
177 |
178 | #get note summary
179 | @api_view(['POST'])
180 | # @login_required
181 | def get_summary(request):
182 | if request.method == 'POST':
183 | json_data = request.data
184 | note_id = json_data['note_id']
185 | note = Notes.objects.get(id = note_id)
186 |
187 | #url for ml server for summary
188 | ml_server_url = "http://717830fd426d.ngrok.io/summarize"
189 | data = requests.post(ml_server_url, data = {'note_text': strip_tags(note.content)})
190 | summary = json.loads(data.text)['summary']
191 | return Response({'Message':"recieved summary", 'data': summary},status=status.HTTP_200_OK)
192 |
193 |
194 | # get note from image, pass to ocr flask server get text,
195 | # send text to summary generation flask, send this summary to frontend
196 | @api_view(['POST'])
197 | @login_required
198 | def get_image_content_summary(request):
199 | if request.method == 'POST':
200 | img_data = request.FILES['file'].read()
201 | img_string = base64.b64encode(img_data)
202 |
203 | #url for ml server image to text
204 | ml_server_url = "http://717830fd426d.ngrok.io/ocr"
205 | data = requests.post(ml_server_url, data = {'img_base64': img_string})
206 | note_text = json.loads(data.text)['image_text']
207 |
208 | #url for ml server image to text
209 | ml_server_url = "http://717830fd426d.ngrok.io/summary"
210 | data = requests.post(ml_server_url, data = {'note_text': note_text})
211 | summary = json.loads(data.text)['summary']
212 | return Response({'Message':"recieved summary from image", 'data': summary},status=status.HTTP_200_OK)
213 |
214 |
215 | #get text from frontend, pass to flask server, then the flashcards generated are passed to frontend again
216 | @api_view(['POST'])
217 | # @login_required
218 | def get_flashcards(request):
219 | if request.method == 'POST':
220 | json_data = request.data
221 | note_id = json_data['note_id']
222 | number_of_flashcards = json_data['number_of_flashcards']
223 | note = Notes.objects.get(id = note_id)
224 |
225 | #url for ml server flashcards
226 | ml_server_url = "http://717830fd426d.ngrok.io/flashcards"
227 | data = requests.post(ml_server_url, data = {'note_text': note.content, 'number_of_flashcards': number_of_flashcards})
228 | flashcards = json.loads(data.text)['flashcards']
229 | print(flashcards)
230 | return Response({'Message':"recieved all flashcards from text", 'data': flashcards},status=status.HTTP_200_OK)
231 |
232 |
233 | # get note from image, pass to ocr flask server get text,
234 | # send text to flashcards generation flask, send this flashcardss to frontend
235 | @api_view(['POST'])
236 | @login_required
237 | def get_image_content_flashcards(request):
238 | if request.method == 'POST':
239 | json_data = request.data
240 | number_of_flashcards = json_data['number_of_flashcards']
241 |
242 | img_data = request.FILES['file'].read()
243 | img_string = base64.b64encode(img_data)
244 |
245 | #url for ml server image to text
246 | ml_server_url = "http://717830fd426d.ngrok.io/ocr"
247 | data = requests.post(ml_server_url, data = {'img_base64': img_string})
248 | note_text = json.loads(data.text)['image_text']
249 |
250 | #url for ml server flashcards generation
251 | ml_server_url = "http://717830fd426d.ngrok.io/flashcards"
252 | data = requests.post(ml_server_url, data = {'note_text': note_text, 'number_of_flashcards': number_of_flashcards})
253 | flashcards = json.loads(data.text)['flashcards']
254 | return Response({'Message':"recieved all flashcards", 'data': flashcards},status=status.HTTP_200_OK)
255 |
256 |
257 |
258 | # {
259 | # "email_id": "deepmatrix_user@gmail.com",
260 | # "password" : "deep@123",
261 | # "username" : "deepmatrix_user"
262 | # }
263 |
264 | # {
265 | # "Message": "User has been logged in",
266 | # "user": [
267 | # {
268 | # "id": 2,
269 | # "password": "deep@123",
270 | # "last_login": null,
271 | # "is_superuser": false,
272 | # "username": "deepmatrix_user",
273 | # "first_name": "",
274 | # "last_name": "",
275 | # "email": "deepmatrix_user@gmail.com",
276 | # "is_staff": false,
277 | # "is_active": true,
278 | # "date_joined": "2021-04-03T09:32:04.010753Z",
279 | # "groups": [],
280 | # "user_permissions": []
281 | # }
282 | # ],
283 | # "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoyfQ.l0ALEx_SFU71zFL-LEhGSBVJJ2-eUufEyCTjlVJqiEA"
284 | # }
285 |
286 |
287 | # {
288 | # "note_title" : "My Note Title",
289 | # "note_content" : "Note Content",
290 | # "user_id" : "2"
291 | # }
292 |
293 |
294 | # {
295 | # "note_id": "2",
296 | # "note_title" : "Hello",
297 | # "note_content" : "Note Content",
298 | # "user_id" : "2"
299 | # }
300 |
301 |
--------------------------------------------------------------------------------
/manage.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | """Django's command-line utility for administrative tasks."""
3 | import os
4 | import sys
5 |
6 |
7 | def main():
8 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'web.settings')
9 | try:
10 | from django.core.management import execute_from_command_line
11 | except ImportError as exc:
12 | raise ImportError(
13 | "Couldn't import Django. Are you sure it's installed and "
14 | "available on your PYTHONPATH environment variable? Did you "
15 | "forget to activate a virtual environment?"
16 | ) from exc
17 | execute_from_command_line(sys.argv)
18 |
19 |
20 | if __name__ == '__main__':
21 | main()
22 |
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | django
2 | djangorestframework
3 | djangorestframework-simplejwt
4 | PyJWT
5 | django-cors-headers
--------------------------------------------------------------------------------
/web/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Deep-Matrix/qgen-backend/9f5e0c727e9f3b74b96a79a92e0aac34b6056b1a/web/__init__.py
--------------------------------------------------------------------------------
/web/asgi.py:
--------------------------------------------------------------------------------
1 | """
2 | ASGI config for web project.
3 |
4 | It exposes the ASGI callable as a module-level variable named ``application``.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/3.0/howto/deployment/asgi/
8 | """
9 |
10 | import os
11 |
12 | from django.core.asgi import get_asgi_application
13 |
14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'web.settings')
15 |
16 | application = get_asgi_application()
17 |
--------------------------------------------------------------------------------
/web/settings.py:
--------------------------------------------------------------------------------
1 | import os
2 | # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
3 | BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
4 |
5 |
6 | # Quick-start development settings - unsuitable for production
7 | # See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
8 |
9 | # SECURITY WARNING: keep the secret key used in production secret!
10 | SECRET_KEY = 'g=(lekaef7-hj)y-g*^q2bpd60je)&2621qln43+0k!4ethp=d'
11 |
12 | # SECURITY WARNING: don't run with debug turned on in production!
13 | DEBUG = True
14 |
15 | ALLOWED_HOSTS = ['*']
16 |
17 | # Application definition
18 |
19 | INSTALLED_APPS = [
20 | 'django.contrib.admin',
21 | 'django.contrib.auth',
22 | 'django.contrib.contenttypes',
23 | 'django.contrib.sessions',
24 | 'django.contrib.messages',
25 | 'django.contrib.staticfiles',
26 | 'rest_framework',
27 | 'base',
28 | 'corsheaders',
29 | 'jwt',
30 | 'djrichtextfield'
31 | ]
32 |
33 | MIDDLEWARE = [
34 | 'django.middleware.security.SecurityMiddleware',
35 | 'django.contrib.sessions.middleware.SessionMiddleware',
36 | 'django.middleware.common.CommonMiddleware',
37 | 'django.middleware.csrf.CsrfViewMiddleware',
38 | 'django.contrib.auth.middleware.AuthenticationMiddleware',
39 | 'django.contrib.messages.middleware.MessageMiddleware',
40 | 'django.middleware.clickjacking.XFrameOptionsMiddleware',
41 | 'corsheaders.middleware.CorsMiddleware'
42 | ]
43 |
44 | ROOT_URLCONF = 'web.urls'
45 |
46 | TEMPLATES = [
47 | {
48 | 'BACKEND': 'django.template.backends.django.DjangoTemplates',
49 | 'DIRS': [],
50 | 'APP_DIRS': True,
51 | 'OPTIONS': {
52 | 'context_processors': [
53 | 'django.template.context_processors.debug',
54 | 'django.template.context_processors.request',
55 | 'django.contrib.auth.context_processors.auth',
56 | 'django.contrib.messages.context_processors.messages',
57 | ],
58 | },
59 | },
60 | ]
61 |
62 | WSGI_APPLICATION = 'web.wsgi.application'
63 |
64 | REST_FRAMEWORK = {
65 | 'DEFAULT_AUTHENTICATION_CLASSES':[
66 | 'rest_framework_simplejwt.authentication.JWTAuthentication',
67 | ],
68 | }
69 |
70 | # Database
71 | # https://docs.djangoproject.com/en/3.0/ref/settings/#databases
72 | DATABASES = {
73 | 'default': {
74 | 'ENGINE': 'django.db.backends.sqlite3',
75 | 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
76 | }
77 | }
78 |
79 | DJRICHTEXTFIELD_CONFIG = {
80 | 'js': ['//cdn.tiny.cloud/1/no-api-key/tinymce/5/tinymce.min.js'],
81 | 'init_template': 'djrichtextfield/init/tinymce.js',
82 | 'settings': {
83 | 'menubar': False,
84 | 'plugins': 'link image',
85 | 'toolbar': 'bold italic | link image | removeformat',
86 | 'width': 700
87 | }
88 | }
89 |
90 | # Password validation
91 | # https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators
92 |
93 | AUTH_PASSWORD_VALIDATORS = [
94 | {
95 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
96 | },
97 | {
98 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
99 | },
100 | {
101 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
102 | },
103 | {
104 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
105 | },
106 | ]
107 |
108 | APPEND_SLASH=False
109 |
110 | # Internationalization
111 | # https://docs.djangoproject.com/en/3.0/topics/i18n/
112 |
113 | LANGUAGE_CODE = 'en-us'
114 |
115 | TIME_ZONE = 'UTC'
116 |
117 | USE_I18N = True
118 |
119 | USE_L10N = True
120 |
121 | USE_TZ = True
122 |
123 | CORS_ORIGIN_ALLOW_ALL = True
124 | # Static files (CSS, JavaScript, Images)
125 | # https://docs.djangoproject.com/en/3.0/howto/static-files/
126 |
127 | STATIC_URL = '/static/'
128 |
--------------------------------------------------------------------------------
/web/urls.py:
--------------------------------------------------------------------------------
1 | from django.contrib import admin
2 | from django.urls import path,include
3 |
4 |
5 | urlpatterns = [
6 | path('admin/', admin.site.urls),
7 | path('api/',include('base.urls')),
8 | path('djrichtextfield/', include('djrichtextfield.urls'))
9 | ]
10 |
--------------------------------------------------------------------------------
/web/wsgi.py:
--------------------------------------------------------------------------------
1 | """
2 | WSGI config for web project.
3 |
4 | It exposes the WSGI callable as a module-level variable named ``application``.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/3.0/howto/deployment/wsgi/
8 | """
9 |
10 | import os
11 |
12 | from django.core.wsgi import get_wsgi_application
13 |
14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'web.settings')
15 |
16 | application = get_wsgi_application()
--------------------------------------------------------------------------------