devwiki:litestar

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
devwiki:litestar [2023/08/25 09:17] – [Concepts] yingdevwiki:litestar [2023/08/29 09:31] (current) – [LiteStar syntax] ying
Line 8: Line 8:
       * uvicorn       * uvicorn
       * jsbeautifier       * jsbeautifier
 +
 +====== LiteStar syntax ======
 +
 +  * after build a simple api, to interact with that web api, sample code
 +    * get <code python>response = requests.get("http://127.0.0.1:8000/?done=true")</code>
 +    * post <code python>response = requests.post("http://127.0.0.1:8000/",json={"title":"car-washing","done":False})</code>
 +    * put <code python>response = requests.put("http://127.0.0.1:8000/profiting", json={"title":"profiting2","done":True}</code>
 +    * read <code>data = response.json()</code>
 +
 +  * note: 
 +    * in json, true is "true"
 +    * in python, true is "True"
 +    * in http url, true is ok with "true" or "True"
  
 ====== Concepts ====== ====== Concepts ======
Line 22: Line 35:
 </code> </code>
  
 +  * ASGI: Asynchronous Server Gateway Interface
 +    * newer for python, non block commu
 +  * WSGI: Web Server Gateway Interface
 +
 +  * litestar use Uvicorn ASGI server, which support http, websockets and other realtime protocol
 +    * https://www.uvicorn.org/
 +
 +  * litestar auto create the scheme and scheme tryout page
 +    * http://127.0.0.1:8000/schema/
 +    * http://127.0.0.1:8000/schema/swagger
 +    * Litestar generates an OpenAPI schema based on the route handlers, which can then be used by Swagger to set up the interactive documentation.
  • devwiki/litestar.txt
  • Last modified: 2023/08/29 09:31
  • by ying