Reference the redis-om-fastapi project
This commit is contained in:
		
							parent
							
								
									269d44c26e
								
							
						
					
					
						commit
						60fbd09775
					
				
					 1 changed files with 5 additions and 4 deletions
				
			
		| 
						 | 
					@ -28,7 +28,7 @@ This example shows how to manage these two uses of Redis within the same applica
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## Example app code
 | 
					## Example app code
 | 
				
			||||||
 | 
					
 | 
				
			||||||
This is a complete example that you can run as-is:
 | 
					Let's look at an example FastAPI app that uses Redis OM. I'll include the code here, but to actually run the example, you'll want to check out the [redis-om-fastapi](https://github.com/redis-developer/redis-om-fastapi) repository from GitHub, which includes the `pyproject.toml` file needed to install the app's dependencies.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```python
 | 
					```python
 | 
				
			||||||
import datetime
 | 
					import datetime
 | 
				
			||||||
| 
						 | 
					@ -105,7 +105,7 @@ async def startup():
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## Testing the app
 | 
					## Testing the app
 | 
				
			||||||
 | 
					
 | 
				
			||||||
You should install the app's dependencies first. This app uses Poetry, so you'll want to make sure you have that installed first:
 | 
					You should install the app's dependencies first. This app uses Poetry, so you'll want to make sure you have Poetry installed first:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    $ pip install poetry
 | 
					    $ pip install poetry
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -115,7 +115,7 @@ Then install the dependencies:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Next, start the server:
 | 
					Next, start the server:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    $ poetry run uvicorn --reload main:test
 | 
					    $ poetry run uvicorn --reload main:app
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Then, in another shell, create a customer:
 | 
					Then, in another shell, create a customer:
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
| 
						 | 
					@ -123,7 +123,8 @@ Then, in another shell, create a customer:
 | 
				
			||||||
-01-02"}'
 | 
					-01-02"}'
 | 
				
			||||||
    {"pk":"01FM2G8EP38AVMH7PMTAJ123TA","first_name":"Andrew","last_name":"Brookins","email":"a@example.com","join_date":"2020-01-02","age":38,"bio":""}
 | 
					    {"pk":"01FM2G8EP38AVMH7PMTAJ123TA","first_name":"Andrew","last_name":"Brookins","email":"a@example.com","join_date":"2020-01-02","age":38,"bio":""}
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
Get a copy of the value for "pk" and make another request to get that customer:
 | 
					
 | 
				
			||||||
 | 
					Get a copy of the value for "pk," which is the model's primary key, and make another request to get that customer:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    $ curl "http://localhost:8000/customer/01FM2G8EP38AVMH7PMTAJ123TA"
 | 
					    $ curl "http://localhost:8000/customer/01FM2G8EP38AVMH7PMTAJ123TA"
 | 
				
			||||||
    {"pk":"01FM2G8EP38AVMH7PMTAJ123TA","first_name":"Andrew","last_name":"Brookins","email":"a@example.com","join_date":"2020-01-02","age":38,"bio":""}
 | 
					    {"pk":"01FM2G8EP38AVMH7PMTAJ123TA","first_name":"Andrew","last_name":"Brookins","email":"a@example.com","join_date":"2020-01-02","age":38,"bio":""}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue