Server-Side Scripting/Introduction/Python (FastAPI)

From Wikiversity
Jump to navigation Jump to search[edit | edit source]

# Displays "Hello world!"
# References:

from fastapi import FastAPI
from fastapi.responses import HTMLResponse
import uvicorn

app = FastAPI()

@app.get('/', response_class=HTMLResponse)
async def get_root():
    return "Hello world!"

if __name__ == "__main__":"main:app", host="", port=5000)

Try It[edit | edit source]

Copy and paste the code above into the following free online development environment or use your own Python (FastAPI) compiler / interpreter / IDE.

See Also[edit | edit source]