Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@rahul-yr
Created June 15, 2022 09:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rahul-yr/7588c7a053ce15b31795e004063e3014 to your computer and use it in GitHub Desktop.
Save rahul-yr/7588c7a053ce15b31795e004063e3014 to your computer and use it in GitHub Desktop.
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