{"id":25178159,"url":"https://github.com/mmoehabb/trivia-udacity-project2","last_synced_at":"2025-08-09T04:12:56.259Z","repository":{"id":116061236,"uuid":"348476061","full_name":"mmoehabb/trivia-udacity-project2","owner":"mmoehabb","description":null,"archived":false,"fork":false,"pushed_at":"2021-03-19T20:25:23.000Z","size":179,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-09T14:52:33.062Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mmoehabb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-03-16T20:00:32.000Z","updated_at":"2021-03-19T20:25:25.000Z","dependencies_parsed_at":null,"dependency_job_id":"05ed8951-f0c6-4b84-87eb-6293a61de3f3","html_url":"https://github.com/mmoehabb/trivia-udacity-project2","commit_stats":null,"previous_names":["mmoehabb/trivia-udacity-project2"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmoehabb%2Ftrivia-udacity-project2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmoehabb%2Ftrivia-udacity-project2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmoehabb%2Ftrivia-udacity-project2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmoehabb%2Ftrivia-udacity-project2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mmoehabb","download_url":"https://codeload.github.com/mmoehabb/trivia-udacity-project2/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247113954,"owners_count":20885844,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-09T14:52:38.627Z","updated_at":"2025-04-04T03:22:49.567Z","avatar_url":"https://github.com/mmoehabb.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Full Stack Trivia API\n\n## Getting Started\n\n- Base URL: The backend is hosted at the default, ```http://localhost:5000/```. And the front end at port 3000.\n- Authentication: No authentication needed.\n\n### Installing Dependencies (backend)\n\n#### Python 3.7\n\nFollow instructions to install the latest version of python for your platform in the [python docs](https://docs.python.org/3/using/unix.html#getting-and-installing-the-latest-version-of-python)\n\n#### PIP Dependencies\n\nOnce you have your virtual environment setup and running, install dependencies by naviging to the `/backend` directory and running:\n\n```bash\npip install -r requirements.txt\n```\n\nThis will install all of the required packages we selected within the `requirements.txt` file.\n\n## Database Setup (optional)\nWith Postgres running, restore a database using the trivia.psql file provided. From the backend folder in terminal run:\n```bash\npsql trivia \u003c trivia.psql\n```\n\n## Running the server\n\nFrom within the `backend` directory first ensure you are working using your created virtual environment.\n\nTo run the server, execute:\n\n```bash\nexport FLASK_APP=flaskr\nexport FLASK_ENV=development\nflask run\n```\n\nSetting the `FLASK_ENV` variable to `development` will detect file changes and restart the server automatically.\n\nSetting the `FLASK_APP` variable to `flaskr` directs flask to use the `flaskr` directory and the `__init__.py` file to find the application.\n\n### Installing Dependencies (frontend)\n\n#### Installing Node and NPM\n\nThis project depends on Nodejs and Node Package Manager (NPM). Before continuing, you must download and install Node (the download includes NPM) from [https://nodejs.com/en/download](https://nodejs.org/en/download/).\n\n#### Installing project dependencies\n\nThis project uses NPM to manage software dependencies. NPM Relies on the package.json file located in the `frontend` directory of this repository. After cloning, open your terminal and run:\n\n```\nnpm install\n```\n\n## Running Your Frontend in Dev Mode\n\nThe frontend app was built using create-react-app. In order to run the app in development mode use ```npm start```.\n\n## Error Handling\n\nErrors are returned as JSON objects in the following format\n\n```\n{\n\t'success': False,\n\t'error': 400,\n\t'message': \"bad request\"\n}\n```\n\nThe api will return two error types when requests fail:\n\n- 404: Resource Not Found\n- 405: Method Not Allowed\n- 422: Not Processable\n\n## Endpoints\n\n### GET '/categories'\n\n- Fetches a dictionary of categories in which the keys are the ids and the value is the corresponding string of the category\n- Request Arguments: None\n- Returns: An object with a single key, categories, that contains an object of id: category_string key:value pairs.\n```\n{\n\t'1' : \"Science\",\n\t'2' : \"Art\",\n\t'3' : \"Geography\",\n\t'4' : \"History\",\n\t'5' : \"Entertainment\",\n\t'6' : \"Sports\"\n}\n```\n\n### GET '/questions'\n\n- Fetches a list of ten questions objects (json), according to the number of the desired page.\n- Request Arguments: The number of the page (NOT mandatory)\n- Returns: An object with four keys (questions, total_questions, current_category, categories).\n```\n{\n\t'questions': [\n\t\t\t{'id': 1, 'question': \"What...\", ....},\n\t\t\t{'id': 2, 'question': \"What...\", ....},\n\t\t\t...\n\t\t],\n\t'total_questions': 123, // total number of questions in the database\n\t'current_category': None,\n\t'categories': {'1': 'Science', '2': \"Art\", ...}\n}\n```\n\n### DELETE '/questions/1'\n\n- Deletes the question, that has id 1, from the database.\n- Request Arguments: None\n- Returns: An object with two keys (success \u0026 message).\n```\n{\n\t'success': True,\n\t'message': f\"Question {question_id} has been deleted.\"\n}\n```\n\n### POST '/questions'\n\n- Inserts new question into the database.\n- Request Arguments: Question and Answer texts, category id and difficulty level.\n- Returns: An object with two keys (success \u0026 message)\n```\n{\n\t'success': True,\n\t'message': 'A new question has been added.'\n}\n```\n\n### POST '/questions/search'\n\n- Fetches all question that contains the searchTerm, in its text.\n- Request Arguments: searchTerm value.\n- Returns: An object with three keys (questions, total_questions and current_category)\n```\n{\n\t'questions': [\n\t\t\t{'id': 1, 'question': \"What...\", ....},\n\t\t\t{'id': 2, 'question': \"What...\", ....},\n\t\t\t...\n\t\t],\n\t'total_questions': 123, // total number of questions in the database\n\t'current_category': None,\n}\n```\n\n### GET '/categories/1/questions'\n\n- Fetches all question, that belongs to a specific category which has id 1.\n- Request Arguments: None\n- Returns: An object with three keys (questions, total_questions and current_category)\n```\n{\n\t'questions': [\n\t\t\t{'id': 1, 'question': \"What...\", ....},\n\t\t\t{'id': 2, 'question': \"What...\", ....},\n\t\t\t...\n\t\t],\n\t'total_questions': 123, // total number of questions in the database\n\t'current_category': {'id': 1, 'type': \"Science\"}\n}\n```\n\n### POST '/quizzes'\n\n- Fetches a random question from the database, within a specific category or not.\n- Request Arguments: An category object with two keys (id \u0026 type), \n\t\t\t\t\t and list of the previous question.\n- Returns: An object with a single key, question, that maps to an object the question info.\n```\n{\n\t'question': {\n\t\t'id': 1, \n\t\t'question': \"...\", \n\t\t'answer': \"...\", \n\t\t'category': 1, \n\t\t'difficulty': 1\n\t}\n}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmmoehabb%2Ftrivia-udacity-project2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmmoehabb%2Ftrivia-udacity-project2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmmoehabb%2Ftrivia-udacity-project2/lists"}