write a simple fastapi server, make it do something useful please
- User
write a simple fastapi server, make it do something useful please
- Assistant
Certainly! FastAPI is a modern, fast (high-performance), web framework for building APIs with Python 3.7+ based on standard Python type hints. It's easy to get started with and it's a great choice for building simple and useful APIs. Here's an example of a simple FastAPI server that performs a basic task:
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: str = None): return {"item_id": item_id, "q": q}In this example, the server defines two endpoints: a root endpoint that returns a simple greeting, and an endpoint that takes an as a path parameter and an optional query parameter.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.