Skip to content

Instantly share code, notes, and snippets.

@rahul-yr
Created Jun 15, 2022
Embed
What would you like to do?
Here I defined all the required methods for url_shorteners
from pydantic import BaseModel
# Define the model for the URL
class CreateUrlShortener(BaseModel):
url: str
# Config for pydantic to validate the data in the request body
class Config:
orm_mode = True
# Define the model for the URL Response
class CreateUrlShortenerResponse(BaseModel):
# short_url is the short url generated by the server
short_url: str
url: str
# Config for pydantic to validate the data in the request body
class Config:
orm_mode = True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment