This API was created to make different requests
- /jokes : Returns a random joke
- /jokes?joke_type=chuck : Returns a joke from the API https://api.chucknorris.io
- /jokes?joke_type=dad : Returns a joke from the API https://icanhazdadjoke.com/api
- /save_joke : Save the text of the joke in the database
- /update_joke/{joke_id} : Update the joke text in the database based on the id
- /delete_joke/{joke_id} : Delete the joke text in the database based on id
- /lcm : Calculates the least common multiple of a list of numbers greater than 0
- /increment : Increases the entered number by 1
https://github.com/Danielmc09/FastAPIJoke.gitcreate:
virtualenv name_env
activate:
On Unix or MacOS, using the bash shell: source venv/bin/activate
On Windows using the Command Prompt: path\venv\Scripts\activate.batpip install -r requirements.txt- Keep in mind that the database used in this project is PostgreSQL, so the reference in the .env file is to the connection to PostgreSQL
DATABASE_URL=postgresql://user:password@localhost/NombreDeTuDBuvicorn main:app --reload- Remember to create the database before running the created_db.py file keep in mind to create an .env file based on the .env.example file and modify it with your information
- python config/created_db.py- pytest test/test_joke.py-
The technologies used in this project can be viewed in the requirements.txt file.
-
The database used in this project is PostgreSQL
-
version python 3.11.3
-
version FastAPI 0.95.0
-
Ports to use that should not be busy or with local services turned off:
- FastAPI: 8000
- PostgreSQL: 5432
| Path | Verb | Body params |
|---|---|---|
| Local | ||
| http://localhost:8000/jokes | GET | joke_type=Optional |
| http://localhost:8000/save_joke | POST | joke=string |
| http://localhost:8000/update_joke/{joke_id} | PUT | joke_id=int |
| http://localhost:8000/delete_joke/{joke_id} | DELETE | joke_id=int |
| http://localhost:8000/lcm | POST | numbers=ListNumber |
| http://localhost:8000/increment | GET | number=int |
| http://localhost:8000/docs | GET | |
| http://localhost:8000/redoc | GET |
Autor: Angel Daniel Menideta Castillo © 2023
