Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Fast api importing optional

from typing import Optional

from fastapi import FastAPI

app = FastAPI()


@app.get("/")
def read_root():
    return {"Hello": "World"}


@app.get("/items/{item_id}")
def read_item(item_id: int, q: Optional[str] = None):
    return {"item_id": item_id, "q": q}
Comment

PREVIOUS NEXT
Code Example
Python :: python array methods 
Python :: python message from teams 
Python :: get query params flask 
Python :: how to take date as input in python 
Python :: python last item in list 
Python :: requests python3 example 
Python :: python array scalar multiplication 
Python :: plotting roc curve 
Python :: create series in pandas 
Python :: python Modulo 10^9+7 (1000000007) 
Python :: how to get prime numbers in a list in python using list comprehension 
Python :: how to make gtts text to speech converter 
Python :: get the time of 1 minute later in python 
Python :: python compare floats 
Python :: find sum numbers in a list in python 
Python :: easy frequency analysis python 
Python :: python thread with return values? 
Python :: selenium element_to_be_clickable PYTHON 
Python :: numpy divide with exception 
Python :: multiple lines input python 
Python :: how to stop a program after 1 second in python 
Python :: numpy remove nan rows 
Python :: transpose of list in python 
Python :: pairplot with selected field 
Python :: pd dataframe single column rename 
Python :: how to merge rows in pandas dataframe 
Python :: represent NaN with pandas in python 
Python :: how to replace a word in text file using python 
Python :: manage.py startapp not working in django 
Python :: # write json file 
ADD CONTENT
Topic
Content
Source link
Name
1+6 =