Skip to content

Some useful Django API for backend development and AI-generated question for Python&Django study!

Notifications You must be signed in to change notification settings

gobbez/DjangoAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 

Repository files navigation

DjangoAPI + AI Python Questions

Some useful Django API CRUD for backend development with Swagger for cool doc!

Plus AI-generated questions for Python&Django study!

Installation

Clone this repo:

git clone https://github.com/gobbez/DjangoAPI

Install requirements.txt:

cd API
pip install requirements.txt

(optional, if you want to use Ollama to create questions)

ollama run gemma2

Create migrations:

python manage.py makemigrations
python manage.py migrate

Launch Django server:

python manage.py runserver

Read the doc with every route and method on Swagger:

http://127.0.0.1:8000/swagger/

Or in Redoc:

http://127.0.0.1:8000/redoc/

Ollama AI-generated questions!

Use Postman to do a Post request and enable Ollama to generate N questions about Python and Django!

How to use

  1. Create migrations and launch your server (python manage.py runserver)
  2. Open Postman and in the Body write a "times": int
  3. (if in local) use this url http://127.0.0.1:8000/addpythonquiz/
  4. Now Ollama will create N rows in the PythonQuiz table!
  • Play Game *
  1. Use Postman (or browser) to send a GET request and start your study-game! This api call will pick a random question from the table
  2. In the Postman send a POST request with the body as a Json format with: { "quizmode": "true", "username": "YOUR_USERNAME", "quest_id": "QUESTION_ID", "answer": "YOUR_ANSWER", }
  3. This will enable you to play the game, and get a right or wrong answer (with points)

GET functions

You can do different GET functions passing the "ask" param, I list them below:

  • showusers = Show all Users table
  • showtotquiz = Show the total quiz in the PythonQuiz table
  • randomquiz = Get a random quiz from the PythonQuiz table, even those you have already answered
  • newquiz = Get a random quiz that you haven't answered yet
  • wrongquiz = Get a random quiz from those that you have it wrong

POST functions

You can do different POST functions passing the "quizmode" param, I list them below:

  • true = Enable the game. You can answer a question (use one of the above GET functions to see the question!). In this mode the answer will be saved in the right or wrong Users column to enable "newquiz" or "wrongquiz" GET functions.
  • not true = Make Ollama create N questions in the PythonQuiz table (use "times" param to say how many questions to add!)

Enjoy!

About

Some useful Django API for backend development and AI-generated question for Python&Django study!

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages