├── .DS_Store
├── .flake8
├── .gitignore
├── LICENSE
├── README.md
├── app
├── __init__.py
├── applications.py
├── background.py
├── concurrency.py
├── datastructures.py
├── dependencies
│ ├── __init__.py
│ ├── models.py
│ └── utils.py
├── encoders.py
├── exception_handlers.py
├── exceptions.py
├── logger.py
├── middleware
│ ├── __init__.py
│ ├── cors.py
│ ├── gzip.py
│ ├── httpsredirect.py
│ ├── trustedhost.py
│ └── wsgi.py
├── openapi
│ ├── __init__.py
│ ├── constants.py
│ ├── docs.py
│ ├── models.py
│ └── utils.py
├── param_functions.py
├── params.py
├── py.typed
├── requests.py
├── responses.py
├── routing.py
├── security
│ ├── __init__.py
│ ├── api_key.py
│ ├── base.py
│ ├── http.py
│ ├── oauth2.py
│ ├── open_id_connect_url.py
│ └── utils.py
├── staticfiles.py
├── templating.py
├── testclient.py
├── types.py
├── utils.py
└── websockets.py
├── mobile
└── todo.tx
├── pyproject.toml
├── resources
├── .eslintignore
├── .eslintrc
├── .github
│ ├── FUNDING.yml
│ ├── ISSUE_TEMPLATE
│ │ └── general.md
│ └── workflows
│ │ └── test.yml
├── .gitignore
├── .npmrc
├── LICENSE
├── README.md
├── cypress.json
├── cypress
│ └── integration
│ │ └── basic.spec.ts
├── index.html
├── locales
│ ├── README.md
│ ├── de.yml
│ ├── en.yml
│ ├── es.yml
│ ├── fr.yml
│ ├── id.yml
│ ├── it.yml
│ ├── ja.yml
│ ├── ko.yml
│ ├── pl.yml
│ ├── pt-BR.yml
│ ├── ru.yml
│ ├── tr.yml
│ ├── vi.yml
│ └── zh-CN.yml
├── netlify.toml
├── package.json
├── pnpm-lock.yaml
├── public
│ ├── _headers
│ ├── favicon.svg
│ ├── pwa-192x192.png
│ ├── pwa-512x512.png
│ ├── robots.txt
│ └── safari-pinned-tab.svg
├── src
│ ├── App.vue
│ ├── auto-imports.d.ts
│ ├── components.d.ts
│ ├── components
│ │ ├── Counter.vue
│ │ ├── Footer.vue
│ │ └── README.md
│ ├── composables
│ │ ├── dark.ts
│ │ └── index.ts
│ ├── layouts
│ │ ├── 404.vue
│ │ ├── README.md
│ │ ├── default.vue
│ │ └── home.vue
│ ├── main.ts
│ ├── modules
│ │ ├── README.md
│ │ ├── i18n.ts
│ │ ├── nprogress.ts
│ │ ├── pinia.ts
│ │ └── pwa.ts
│ ├── pages
│ │ ├── README.md
│ │ ├── [...all].vue
│ │ ├── about.md
│ │ ├── hi
│ │ │ └── [name].vue
│ │ └── index.vue
│ ├── shims.d.ts
│ ├── stores
│ │ └── user.ts
│ ├── styles
│ │ ├── main.css
│ │ └── markdown.css
│ └── types.ts
├── test
│ ├── __snapshots__
│ │ └── component.test.ts.snap
│ ├── basic.test.ts
│ └── component.test.ts
├── todo.tx
├── tsconfig.json
├── vite.config.ts
└── windi.config.ts
└── sugar
├── .gitignore
├── docs
├── az
│ ├── mkdocs.yml
│ └── overrides
│ │ └── .gitignore
├── de
│ ├── docs
│ │ ├── features.md
│ │ └── index.md
│ ├── mkdocs.yml
│ └── overrides
│ │ └── .gitignore
├── en
│ ├── data
│ │ ├── external_links.yml
│ │ ├── github_sponsors.yml
│ │ ├── people.yml
│ │ ├── sponsors.yml
│ │ └── sponsors_badge.yml
│ ├── docs
│ │ ├── advanced
│ │ │ ├── additional-responses.md
│ │ │ ├── additional-status-codes.md
│ │ │ ├── advanced-dependencies.md
│ │ │ ├── async-sql-databases.md
│ │ │ ├── async-tests.md
│ │ │ ├── behind-a-proxy.md
│ │ │ ├── conditional-openapi.md
│ │ │ ├── custom-request-and-route.md
│ │ │ ├── custom-response.md
│ │ │ ├── dataclasses.md
│ │ │ ├── events.md
│ │ │ ├── extending-openapi.md
│ │ │ ├── graphql.md
│ │ │ ├── index.md
│ │ │ ├── middleware.md
│ │ │ ├── nosql-databases.md
│ │ │ ├── openapi-callbacks.md
│ │ │ ├── path-operation-advanced-configuration.md
│ │ │ ├── response-change-status-code.md
│ │ │ ├── response-cookies.md
│ │ │ ├── response-directly.md
│ │ │ ├── response-headers.md
│ │ │ ├── security
│ │ │ │ ├── http-basic-auth.md
│ │ │ │ ├── index.md
│ │ │ │ └── oauth2-scopes.md
│ │ │ ├── settings.md
│ │ │ ├── sql-databases-peewee.md
│ │ │ ├── sub-applications.md
│ │ │ ├── templates.md
│ │ │ ├── testing-database.md
│ │ │ ├── testing-dependencies.md
│ │ │ ├── testing-events.md
│ │ │ ├── testing-websockets.md
│ │ │ ├── using-request-directly.md
│ │ │ ├── websockets.md
│ │ │ └── wsgi.md
│ │ ├── alternatives.md
│ │ ├── async.md
│ │ ├── benchmarks.md
│ │ ├── contributing.md
│ │ ├── css
│ │ │ ├── custom.css
│ │ │ └── termynal.css
│ │ ├── deployment
│ │ │ ├── concepts.md
│ │ │ ├── deta.md
│ │ │ ├── docker.md
│ │ │ ├── https.md
│ │ │ ├── index.md
│ │ │ ├── manually.md
│ │ │ ├── server-workers.md
│ │ │ └── versions.md
│ │ ├── external-links.md
│ │ ├── fastapi-people.md
│ │ ├── features.md
│ │ ├── help-fastapi.md
│ │ ├── history-design-future.md
│ │ ├── img
│ │ │ ├── deployment
│ │ │ │ ├── concepts
│ │ │ │ │ ├── image01.png
│ │ │ │ │ ├── process-ram.drawio
│ │ │ │ │ └── process-ram.svg
│ │ │ │ ├── deta
│ │ │ │ │ ├── image01.png
│ │ │ │ │ └── image02.png
│ │ │ │ └── https
│ │ │ │ │ ├── https.drawio
│ │ │ │ │ ├── https.svg
│ │ │ │ │ ├── https01.drawio
│ │ │ │ │ ├── https01.svg
│ │ │ │ │ ├── https02.drawio
│ │ │ │ │ ├── https02.svg
│ │ │ │ │ ├── https03.drawio
│ │ │ │ │ ├── https03.svg
│ │ │ │ │ ├── https04.drawio
│ │ │ │ │ ├── https04.svg
│ │ │ │ │ ├── https05.drawio
│ │ │ │ │ ├── https05.svg
│ │ │ │ │ ├── https06.drawio
│ │ │ │ │ ├── https06.svg
│ │ │ │ │ ├── https07.drawio
│ │ │ │ │ ├── https07.svg
│ │ │ │ │ ├── https08.drawio
│ │ │ │ │ └── https08.svg
│ │ │ ├── favicon.png
│ │ │ ├── github-social-preview.png
│ │ │ ├── github-social-preview.svg
│ │ │ ├── icon-transparent-bg.png
│ │ │ ├── icon-white-bg.png
│ │ │ ├── icon-white.svg
│ │ │ ├── index
│ │ │ │ ├── index-01-swagger-ui-simple.png
│ │ │ │ ├── index-02-redoc-simple.png
│ │ │ │ ├── index-03-swagger-02.png
│ │ │ │ ├── index-04-swagger-03.png
│ │ │ │ ├── index-05-swagger-04.png
│ │ │ │ └── index-06-redoc-02.png
│ │ │ ├── logo-margin
│ │ │ │ ├── logo-teal-vector.svg
│ │ │ │ ├── logo-teal.png
│ │ │ │ ├── logo-teal.svg
│ │ │ │ └── logo-white-bg.png
│ │ │ ├── logo-teal-vector.svg
│ │ │ ├── logo-teal.svg
│ │ │ ├── pycharm-completion.png
│ │ │ ├── python-types
│ │ │ │ ├── image01.png
│ │ │ │ ├── image02.png
│ │ │ │ ├── image03.png
│ │ │ │ ├── image04.png
│ │ │ │ ├── image05.png
│ │ │ │ └── image06.png
│ │ │ ├── sponsors
│ │ │ │ ├── calmcode.jpg
│ │ │ │ ├── cryptapi-banner.svg
│ │ │ │ ├── cryptapi.svg
│ │ │ │ ├── deta-banner.svg
│ │ │ │ ├── deta.svg
│ │ │ │ ├── fastapi-course-bundle-banner.svg
│ │ │ │ ├── haystack-fastapi.svg
│ │ │ │ ├── investsuite.svg
│ │ │ │ ├── jina-banner.svg
│ │ │ │ ├── jina.svg
│ │ │ │ ├── talkpython.png
│ │ │ │ ├── testdriven.svg
│ │ │ │ ├── vimso.png
│ │ │ │ └── wetransfer.svg
│ │ │ ├── tutorial
│ │ │ │ ├── additional-responses
│ │ │ │ │ └── image01.png
│ │ │ │ ├── async-sql-databases
│ │ │ │ │ └── image01.png
│ │ │ │ ├── behind-a-proxy
│ │ │ │ │ ├── image01.png
│ │ │ │ │ ├── image02.png
│ │ │ │ │ └── image03.png
│ │ │ │ ├── bigger-applications
│ │ │ │ │ ├── image01.png
│ │ │ │ │ ├── package.drawio
│ │ │ │ │ └── package.svg
│ │ │ │ ├── body-fields
│ │ │ │ │ ├── image01.png
│ │ │ │ │ └── image02.png
│ │ │ │ ├── body-nested-models
│ │ │ │ │ └── image01.png
│ │ │ │ ├── body
│ │ │ │ │ ├── image01.png
│ │ │ │ │ ├── image02.png
│ │ │ │ │ ├── image03.png
│ │ │ │ │ ├── image04.png
│ │ │ │ │ └── image05.png
│ │ │ │ ├── custom-response
│ │ │ │ │ └── image01.png
│ │ │ │ ├── dataclasses
│ │ │ │ │ └── image01.png
│ │ │ │ ├── debugging
│ │ │ │ │ ├── image01.png
│ │ │ │ │ └── image02.png
│ │ │ │ ├── dependencies
│ │ │ │ │ ├── image01.png
│ │ │ │ │ └── image02.png
│ │ │ │ ├── extending-openapi
│ │ │ │ │ └── image01.png
│ │ │ │ ├── graphql
│ │ │ │ │ └── image01.png
│ │ │ │ ├── metadata
│ │ │ │ │ ├── image01.png
│ │ │ │ │ └── image02.png
│ │ │ │ ├── openapi-callbacks
│ │ │ │ │ └── image01.png
│ │ │ │ ├── path-operation-advanced-configuration
│ │ │ │ │ └── image01.png
│ │ │ │ ├── path-operation-configuration
│ │ │ │ │ ├── image01.png
│ │ │ │ │ ├── image02.png
│ │ │ │ │ ├── image03.png
│ │ │ │ │ ├── image04.png
│ │ │ │ │ └── image05.png
│ │ │ │ ├── path-params
│ │ │ │ │ ├── image01.png
│ │ │ │ │ ├── image02.png
│ │ │ │ │ └── image03.png
│ │ │ │ ├── query-params-str-validations
│ │ │ │ │ ├── image01.png
│ │ │ │ │ └── image02.png
│ │ │ │ ├── response-model
│ │ │ │ │ ├── image01.png
│ │ │ │ │ └── image02.png
│ │ │ │ ├── response-status-code
│ │ │ │ │ ├── image01.png
│ │ │ │ │ └── image02.png
│ │ │ │ ├── security
│ │ │ │ │ ├── image01.png
│ │ │ │ │ ├── image02.png
│ │ │ │ │ ├── image03.png
│ │ │ │ │ ├── image04.png
│ │ │ │ │ ├── image05.png
│ │ │ │ │ ├── image06.png
│ │ │ │ │ ├── image07.png
│ │ │ │ │ ├── image08.png
│ │ │ │ │ ├── image09.png
│ │ │ │ │ ├── image10.png
│ │ │ │ │ ├── image11.png
│ │ │ │ │ └── image12.png
│ │ │ │ ├── sql-databases
│ │ │ │ │ ├── image01.png
│ │ │ │ │ └── image02.png
│ │ │ │ ├── sub-applications
│ │ │ │ │ ├── image01.png
│ │ │ │ │ └── image02.png
│ │ │ │ └── websockets
│ │ │ │ │ ├── image01.png
│ │ │ │ │ ├── image02.png
│ │ │ │ │ ├── image03.png
│ │ │ │ │ ├── image04.png
│ │ │ │ │ └── image05.png
│ │ │ └── vscode-completion.png
│ │ ├── index.md
│ │ ├── js
│ │ │ ├── chat.js
│ │ │ ├── custom.js
│ │ │ └── termynal.js
│ │ ├── newsletter.md
│ │ ├── project-generation.md
│ │ ├── python-types.md
│ │ ├── release-notes.md
│ │ └── tutorial
│ │ │ ├── background-tasks.md
│ │ │ ├── bigger-applications.md
│ │ │ ├── body-fields.md
│ │ │ ├── body-multiple-params.md
│ │ │ ├── body-nested-models.md
│ │ │ ├── body-updates.md
│ │ │ ├── body.md
│ │ │ ├── cookie-params.md
│ │ │ ├── cors.md
│ │ │ ├── debugging.md
│ │ │ ├── dependencies
│ │ │ ├── classes-as-dependencies.md
│ │ │ ├── dependencies-in-path-operation-decorators.md
│ │ │ ├── dependencies-with-yield.md
│ │ │ ├── global-dependencies.md
│ │ │ ├── index.md
│ │ │ └── sub-dependencies.md
│ │ │ ├── encoder.md
│ │ │ ├── extra-data-types.md
│ │ │ ├── extra-models.md
│ │ │ ├── first-steps.md
│ │ │ ├── handling-errors.md
│ │ │ ├── header-params.md
│ │ │ ├── index.md
│ │ │ ├── metadata.md
│ │ │ ├── middleware.md
│ │ │ ├── path-operation-configuration.md
│ │ │ ├── path-params-numeric-validations.md
│ │ │ ├── path-params.md
│ │ │ ├── query-params-str-validations.md
│ │ │ ├── query-params.md
│ │ │ ├── request-files.md
│ │ │ ├── request-forms-and-files.md
│ │ │ ├── request-forms.md
│ │ │ ├── response-model.md
│ │ │ ├── response-status-code.md
│ │ │ ├── schema-extra-example.md
│ │ │ ├── security
│ │ │ ├── first-steps.md
│ │ │ ├── get-current-user.md
│ │ │ ├── index.md
│ │ │ ├── oauth2-jwt.md
│ │ │ └── simple-oauth2.md
│ │ │ ├── sql-databases.md
│ │ │ ├── static-files.md
│ │ │ └── testing.md
│ ├── mkdocs.yml
│ └── overrides
│ │ └── main.html
├── es
│ ├── docs
│ │ ├── advanced
│ │ │ ├── additional-status-codes.md
│ │ │ ├── index.md
│ │ │ ├── path-operation-advanced-configuration.md
│ │ │ └── response-directly.md
│ │ ├── async.md
│ │ ├── features.md
│ │ ├── index.md
│ │ ├── python-types.md
│ │ └── tutorial
│ │ │ ├── first-steps.md
│ │ │ ├── index.md
│ │ │ ├── path-params.md
│ │ │ └── query-params.md
│ ├── mkdocs.yml
│ └── overrides
│ │ └── .gitignore
├── fr
│ ├── docs
│ │ ├── alternatives.md
│ │ ├── async.md
│ │ ├── deployment
│ │ │ └── docker.md
│ │ ├── external-links.md
│ │ ├── fastapi-people.md
│ │ ├── features.md
│ │ ├── index.md
│ │ ├── project-generation.md
│ │ ├── python-types.md
│ │ └── tutorial
│ │ │ ├── background-tasks.md
│ │ │ ├── body.md
│ │ │ ├── first-steps.md
│ │ │ ├── path-params.md
│ │ │ └── query-params.md
│ ├── mkdocs.yml
│ └── overrides
│ │ └── .gitignore
├── id
│ ├── docs
│ │ └── index.md
│ ├── mkdocs.yml
│ └── overrides
│ │ └── .gitignore
├── it
│ ├── docs
│ │ └── index.md
│ ├── mkdocs.yml
│ └── overrides
│ │ └── .gitignore
├── ja
│ ├── docs
│ │ ├── advanced
│ │ │ ├── additional-status-codes.md
│ │ │ ├── custom-response.md
│ │ │ ├── path-operation-advanced-configuration.md
│ │ │ └── response-directly.md
│ │ ├── alternatives.md
│ │ ├── async.md
│ │ ├── benchmarks.md
│ │ ├── contributing.md
│ │ ├── deployment
│ │ │ ├── deta.md
│ │ │ ├── docker.md
│ │ │ ├── index.md
│ │ │ ├── manually.md
│ │ │ └── versions.md
│ │ ├── external-links.md
│ │ ├── fastapi-people.md
│ │ ├── features.md
│ │ ├── help-fastapi.md
│ │ ├── history-design-future.md
│ │ ├── index.md
│ │ ├── project-generation.md
│ │ └── tutorial
│ │ │ ├── body-updates.md
│ │ │ ├── body.md
│ │ │ ├── cookie-params.md
│ │ │ ├── cors.md
│ │ │ ├── debugging.md
│ │ │ ├── first-steps.md
│ │ │ ├── header-params.md
│ │ │ ├── index.md
│ │ │ ├── middleware.md
│ │ │ ├── path-params.md
│ │ │ ├── query-params-str-validations.md
│ │ │ ├── query-params.md
│ │ │ ├── request-forms.md
│ │ │ ├── security
│ │ │ ├── first-steps.md
│ │ │ └── oauth2-jwt.md
│ │ │ ├── static-files.md
│ │ │ └── testing.md
│ ├── mkdocs.yml
│ └── overrides
│ │ └── .gitignore
├── ko
│ ├── docs
│ │ ├── deployment
│ │ │ └── versions.md
│ │ ├── index.md
│ │ └── tutorial
│ │ │ ├── encoder.md
│ │ │ ├── first-steps.md
│ │ │ ├── header-params.md
│ │ │ ├── index.md
│ │ │ ├── path-params-numeric-validations.md
│ │ │ ├── path-params.md
│ │ │ ├── query-params.md
│ │ │ ├── request-files.md
│ │ │ ├── request-forms-and-files.md
│ │ │ └── response-status-code.md
│ ├── mkdocs.yml
│ └── overrides
│ │ └── .gitignore
├── missing-translation.md
├── pl
│ ├── docs
│ │ └── index.md
│ ├── mkdocs.yml
│ └── overrides
│ │ └── .gitignore
├── pt
│ ├── docs
│ │ ├── advanced
│ │ │ └── index.md
│ │ ├── alternatives.md
│ │ ├── async.md
│ │ ├── benchmarks.md
│ │ ├── contributing.md
│ │ ├── deployment.md
│ │ ├── deployment
│ │ │ ├── https.md
│ │ │ ├── index.md
│ │ │ └── versions.md
│ │ ├── external-links.md
│ │ ├── fastapi-people.md
│ │ ├── features.md
│ │ ├── history-design-future.md
│ │ ├── index.md
│ │ ├── project-generation.md
│ │ ├── python-types.md
│ │ └── tutorial
│ │ │ ├── body-fields.md
│ │ │ ├── first-steps.md
│ │ │ ├── index.md
│ │ │ ├── path-params.md
│ │ │ ├── query-params-str-validations.md
│ │ │ └── security
│ │ │ └── index.md
│ ├── mkdocs.yml
│ └── overrides
│ │ └── .gitignore
├── ru
│ ├── docs
│ │ ├── external-links.md
│ │ ├── index.md
│ │ └── python-types.md
│ ├── mkdocs.yml
│ └── overrides
│ │ └── .gitignore
├── sq
│ ├── docs
│ │ └── index.md
│ ├── mkdocs.yml
│ └── overrides
│ │ └── .gitignore
├── tr
│ ├── docs
│ │ ├── benchmarks.md
│ │ ├── fastapi-people.md
│ │ ├── features.md
│ │ ├── index.md
│ │ └── python-types.md
│ ├── mkdocs.yml
│ └── overrides
│ │ └── .gitignore
├── uk
│ ├── docs
│ │ └── index.md
│ ├── mkdocs.yml
│ └── overrides
│ │ └── .gitignore
└── zh
│ ├── docs
│ ├── advanced
│ │ ├── additional-status-codes.md
│ │ ├── custom-response.md
│ │ ├── index.md
│ │ ├── path-operation-advanced-configuration.md
│ │ └── response-directly.md
│ ├── benchmarks.md
│ ├── contributing.md
│ ├── fastapi-people.md
│ ├── features.md
│ ├── help-fastapi.md
│ ├── index.md
│ ├── python-types.md
│ └── tutorial
│ │ ├── bigger-applications.md
│ │ ├── body-fields.md
│ │ ├── body-multiple-params.md
│ │ ├── body-nested-models.md
│ │ ├── body-updates.md
│ │ ├── body.md
│ │ ├── cookie-params.md
│ │ ├── cors.md
│ │ ├── debugging.md
│ │ ├── dependencies
│ │ ├── dependencies-in-path-operation-decorators.md
│ │ ├── global-dependencies.md
│ │ ├── index.md
│ │ └── sub-dependencies.md
│ │ ├── extra-data-types.md
│ │ ├── extra-models.md
│ │ ├── first-steps.md
│ │ ├── handling-errors.md
│ │ ├── header-params.md
│ │ ├── index.md
│ │ ├── metadata.md
│ │ ├── middleware.md
│ │ ├── path-params-numeric-validations.md
│ │ ├── path-params.md
│ │ ├── query-params-str-validations.md
│ │ ├── query-params.md
│ │ ├── request-files.md
│ │ ├── request-forms-and-files.md
│ │ ├── request-forms.md
│ │ ├── response-model.md
│ │ ├── response-status-code.md
│ │ ├── schema-extra-example.md
│ │ └── security
│ │ ├── get-current-user.md
│ │ ├── index.md
│ │ ├── oauth2-jwt.md
│ │ └── simple-oauth2.md
│ ├── mkdocs.yml
│ └── overrides
│ └── .gitignore
├── docs_src
├── additional_responses
│ ├── tutorial001.py
│ ├── tutorial002.py
│ ├── tutorial003.py
│ └── tutorial004.py
├── additional_status_codes
│ └── tutorial001.py
├── advanced_middleware
│ ├── tutorial001.py
│ ├── tutorial002.py
│ └── tutorial003.py
├── app_testing
│ ├── __init__.py
│ ├── app_b
│ │ ├── __init__.py
│ │ ├── main.py
│ │ └── test_main.py
│ ├── app_b_py310
│ │ ├── __init__.py
│ │ ├── main.py
│ │ └── test_main.py
│ ├── main.py
│ ├── test_main.py
│ ├── tutorial001.py
│ ├── tutorial002.py
│ └── tutorial003.py
├── async_sql_databases
│ └── tutorial001.py
├── async_tests
│ ├── __init__.py
│ ├── main.py
│ └── test_main.py
├── background_tasks
│ ├── tutorial001.py
│ ├── tutorial002.py
│ └── tutorial002_py310.py
├── behind_a_proxy
│ ├── tutorial001.py
│ ├── tutorial002.py
│ ├── tutorial003.py
│ └── tutorial004.py
├── bigger_applications
│ ├── __init__.py
│ └── app
│ │ ├── __init__.py
│ │ ├── dependencies.py
│ │ ├── internal
│ │ ├── __init__.py
│ │ └── admin.py
│ │ ├── main.py
│ │ └── routers
│ │ ├── __init__.py
│ │ ├── items.py
│ │ └── users.py
├── body
│ ├── tutorial001.py
│ ├── tutorial001_py310.py
│ ├── tutorial002.py
│ ├── tutorial002_py310.py
│ ├── tutorial003.py
│ ├── tutorial003_py310.py
│ ├── tutorial004.py
│ └── tutorial004_py310.py
├── body_fields
│ ├── tutorial001.py
│ └── tutorial001_py310.py
├── body_multiple_params
│ ├── tutorial001.py
│ ├── tutorial001_py310.py
│ ├── tutorial002.py
│ ├── tutorial002_py310.py
│ ├── tutorial003.py
│ ├── tutorial003_py310.py
│ ├── tutorial004.py
│ ├── tutorial004_py310.py
│ ├── tutorial005.py
│ └── tutorial005_py310.py
├── body_nested_models
│ ├── tutorial001.py
│ ├── tutorial001_py310.py
│ ├── tutorial002.py
│ ├── tutorial002_py310.py
│ ├── tutorial002_py39.py
│ ├── tutorial003.py
│ ├── tutorial003_py310.py
│ ├── tutorial003_py39.py
│ ├── tutorial004.py
│ ├── tutorial004_py310.py
│ ├── tutorial004_py39.py
│ ├── tutorial005.py
│ ├── tutorial005_py310.py
│ ├── tutorial005_py39.py
│ ├── tutorial006.py
│ ├── tutorial006_py310.py
│ ├── tutorial006_py39.py
│ ├── tutorial007.py
│ ├── tutorial007_py310.py
│ ├── tutorial007_py39.py
│ ├── tutorial008.py
│ ├── tutorial008_py39.py
│ ├── tutorial009.py
│ └── tutorial009_py39.py
├── body_updates
│ ├── tutorial001.py
│ ├── tutorial001_py310.py
│ ├── tutorial001_py39.py
│ ├── tutorial002.py
│ ├── tutorial002_py310.py
│ └── tutorial002_py39.py
├── conditional_openapi
│ └── tutorial001.py
├── cookie_params
│ ├── tutorial001.py
│ └── tutorial001_py310.py
├── cors
│ └── tutorial001.py
├── custom_request_and_route
│ ├── tutorial001.py
│ ├── tutorial002.py
│ └── tutorial003.py
├── custom_response
│ ├── tutorial001.py
│ ├── tutorial001b.py
│ ├── tutorial002.py
│ ├── tutorial003.py
│ ├── tutorial004.py
│ ├── tutorial005.py
│ ├── tutorial006.py
│ ├── tutorial006b.py
│ ├── tutorial006c.py
│ ├── tutorial007.py
│ ├── tutorial008.py
│ ├── tutorial009.py
│ ├── tutorial009b.py
│ └── tutorial010.py
├── dataclasses
│ ├── tutorial001.py
│ ├── tutorial002.py
│ └── tutorial003.py
├── debugging
│ └── tutorial001.py
├── dependencies
│ ├── tutorial001.py
│ ├── tutorial001_py310.py
│ ├── tutorial002.py
│ ├── tutorial002_py310.py
│ ├── tutorial003.py
│ ├── tutorial003_py310.py
│ ├── tutorial004.py
│ ├── tutorial004_py310.py
│ ├── tutorial005.py
│ ├── tutorial005_py310.py
│ ├── tutorial006.py
│ ├── tutorial007.py
│ ├── tutorial008.py
│ ├── tutorial009.py
│ ├── tutorial010.py
│ ├── tutorial011.py
│ └── tutorial012.py
├── dependency_testing
│ └── tutorial001.py
├── encoder
│ ├── tutorial001.py
│ └── tutorial001_py310.py
├── events
│ ├── tutorial001.py
│ └── tutorial002.py
├── extending_openapi
│ ├── tutorial001.py
│ └── tutorial002.py
├── extra_data_types
│ ├── tutorial001.py
│ └── tutorial001_py310.py
├── extra_models
│ ├── tutorial001.py
│ ├── tutorial001_py310.py
│ ├── tutorial002.py
│ ├── tutorial002_py310.py
│ ├── tutorial003.py
│ ├── tutorial003_py310.py
│ ├── tutorial004.py
│ ├── tutorial004_py39.py
│ ├── tutorial005.py
│ └── tutorial005_py39.py
├── first_steps
│ ├── tutorial001.py
│ ├── tutorial002.py
│ └── tutorial003.py
├── graphql
│ └── tutorial001.py
├── handling_errors
│ ├── tutorial001.py
│ ├── tutorial002.py
│ ├── tutorial003.py
│ ├── tutorial004.py
│ ├── tutorial005.py
│ └── tutorial006.py
├── header_params
│ ├── tutorial001.py
│ ├── tutorial001_py310.py
│ ├── tutorial002.py
│ ├── tutorial002_py310.py
│ ├── tutorial003.py
│ ├── tutorial003_py310.py
│ └── tutorial003_py39.py
├── metadata
│ ├── tutorial001.py
│ ├── tutorial002.py
│ ├── tutorial003.py
│ └── tutorial004.py
├── middleware
│ └── tutorial001.py
├── nosql_databases
│ └── tutorial001.py
├── openapi_callbacks
│ └── tutorial001.py
├── path_operation_advanced_configuration
│ ├── tutorial001.py
│ ├── tutorial002.py
│ ├── tutorial003.py
│ ├── tutorial004.py
│ ├── tutorial005.py
│ ├── tutorial006.py
│ └── tutorial007.py
├── path_operation_configuration
│ ├── tutorial001.py
│ ├── tutorial001_py310.py
│ ├── tutorial001_py39.py
│ ├── tutorial002.py
│ ├── tutorial002_py310.py
│ ├── tutorial002_py39.py
│ ├── tutorial003.py
│ ├── tutorial003_py310.py
│ ├── tutorial003_py39.py
│ ├── tutorial004.py
│ ├── tutorial004_py310.py
│ ├── tutorial004_py39.py
│ ├── tutorial005.py
│ ├── tutorial005_py310.py
│ ├── tutorial005_py39.py
│ └── tutorial006.py
├── path_params
│ ├── tutorial001.py
│ ├── tutorial002.py
│ ├── tutorial003.py
│ ├── tutorial004.py
│ └── tutorial005.py
├── path_params_numeric_validations
│ ├── tutorial001.py
│ ├── tutorial001_py310.py
│ ├── tutorial002.py
│ ├── tutorial003.py
│ ├── tutorial004.py
│ ├── tutorial005.py
│ └── tutorial006.py
├── python_types
│ ├── tutorial001.py
│ ├── tutorial002.py
│ ├── tutorial003.py
│ ├── tutorial004.py
│ ├── tutorial005.py
│ ├── tutorial006.py
│ ├── tutorial006_py39.py
│ ├── tutorial007.py
│ ├── tutorial007_py39.py
│ ├── tutorial008.py
│ ├── tutorial008b.py
│ ├── tutorial008b_py310.py
│ ├── tutorial009.py
│ ├── tutorial009_py310.py
│ ├── tutorial009b.py
│ ├── tutorial010.py
│ ├── tutorial011.py
│ ├── tutorial011_py310.py
│ └── tutorial011_py39.py
├── query_params
│ ├── tutorial001.py
│ ├── tutorial002.py
│ ├── tutorial002_py310.py
│ ├── tutorial003.py
│ ├── tutorial003_py310.py
│ ├── tutorial004.py
│ ├── tutorial004_py310.py
│ ├── tutorial005.py
│ ├── tutorial006.py
│ ├── tutorial006_py310.py
│ └── tutorial006b.py
├── query_params_str_validations
│ ├── tutorial001.py
│ ├── tutorial001_py310.py
│ ├── tutorial002.py
│ ├── tutorial002_py310.py
│ ├── tutorial003.py
│ ├── tutorial003_py310.py
│ ├── tutorial004.py
│ ├── tutorial004_py310.py
│ ├── tutorial005.py
│ ├── tutorial006.py
│ ├── tutorial007.py
│ ├── tutorial007_py310.py
│ ├── tutorial008.py
│ ├── tutorial008_py310.py
│ ├── tutorial009.py
│ ├── tutorial009_py310.py
│ ├── tutorial010.py
│ ├── tutorial010_py310.py
│ ├── tutorial011.py
│ ├── tutorial011_py310.py
│ ├── tutorial011_py39.py
│ ├── tutorial012.py
│ ├── tutorial012_py39.py
│ └── tutorial013.py
├── request_files
│ ├── tutorial001.py
│ ├── tutorial002.py
│ └── tutorial002_py39.py
├── request_forms
│ └── tutorial001.py
├── request_forms_and_files
│ └── tutorial001.py
├── response_change_status_code
│ └── tutorial001.py
├── response_cookies
│ ├── tutorial001.py
│ └── tutorial002.py
├── response_directly
│ ├── tutorial001.py
│ └── tutorial002.py
├── response_headers
│ ├── tutorial001.py
│ └── tutorial002.py
├── response_model
│ ├── tutorial001.py
│ ├── tutorial001_py310.py
│ ├── tutorial001_py39.py
│ ├── tutorial002.py
│ ├── tutorial002_py310.py
│ ├── tutorial003.py
│ ├── tutorial003_py310.py
│ ├── tutorial004.py
│ ├── tutorial004_py310.py
│ ├── tutorial004_py39.py
│ ├── tutorial005.py
│ ├── tutorial005_py310.py
│ ├── tutorial006.py
│ └── tutorial006_py310.py
├── response_status_code
│ ├── tutorial001.py
│ └── tutorial002.py
├── schema_extra_example
│ ├── tutorial001.py
│ ├── tutorial001_py310.py
│ ├── tutorial002.py
│ ├── tutorial002_py310.py
│ ├── tutorial003.py
│ ├── tutorial003_py310.py
│ ├── tutorial004.py
│ └── tutorial004_py310.py
├── security
│ ├── tutorial001.py
│ ├── tutorial002.py
│ ├── tutorial002_py310.py
│ ├── tutorial003.py
│ ├── tutorial003_py310.py
│ ├── tutorial004.py
│ ├── tutorial004_py310.py
│ ├── tutorial005.py
│ ├── tutorial005_py310.py
│ ├── tutorial005_py39.py
│ ├── tutorial006.py
│ └── tutorial007.py
├── settings
│ ├── app01
│ │ ├── __init__.py
│ │ ├── config.py
│ │ └── main.py
│ ├── app02
│ │ ├── __init__.py
│ │ ├── config.py
│ │ ├── main.py
│ │ └── test_main.py
│ ├── app03
│ │ ├── __init__.py
│ │ ├── config.py
│ │ └── main.py
│ └── tutorial001.py
├── sql_databases
│ ├── __init__.py
│ ├── sql_app
│ │ ├── __init__.py
│ │ ├── alt_main.py
│ │ ├── crud.py
│ │ ├── database.py
│ │ ├── main.py
│ │ ├── models.py
│ │ ├── schemas.py
│ │ └── tests
│ │ │ ├── __init__.py
│ │ │ └── test_sql_app.py
│ ├── sql_app_py310
│ │ ├── __init__.py
│ │ ├── alt_main.py
│ │ ├── crud.py
│ │ ├── database.py
│ │ ├── main.py
│ │ ├── models.py
│ │ ├── schemas.py
│ │ └── tests
│ │ │ ├── __init__.py
│ │ │ └── test_sql_app.py
│ └── sql_app_py39
│ │ ├── __init__.py
│ │ ├── alt_main.py
│ │ ├── crud.py
│ │ ├── database.py
│ │ ├── main.py
│ │ ├── models.py
│ │ ├── schemas.py
│ │ └── tests
│ │ ├── __init__.py
│ │ └── test_sql_app.py
├── sql_databases_peewee
│ ├── __init__.py
│ └── sql_app
│ │ ├── __init__.py
│ │ ├── crud.py
│ │ ├── database.py
│ │ ├── main.py
│ │ ├── models.py
│ │ └── schemas.py
├── static_files
│ └── tutorial001.py
├── sub_applications
│ └── tutorial001.py
├── templates
│ ├── static
│ │ └── styles.css
│ ├── templates
│ │ └── item.html
│ └── tutorial001.py
├── using_request_directly
│ └── tutorial001.py
├── websockets
│ ├── __init__.py
│ ├── tutorial001.py
│ ├── tutorial002.py
│ └── tutorial003.py
└── wsgi
│ └── tutorial001.py
├── pending_tests
└── main.py
├── scripts
├── build-docs.sh
├── clean.sh
├── docs-live.sh
├── docs.py
├── format.sh
├── gitter_releases_bot.py
├── lint.sh
├── netlify-docs.sh
├── notify.sh
├── publish.sh
├── test-cov-html.sh
├── test.sh
└── zip-docs.sh
└── tests
├── __init__.py
├── main.py
├── test_additional_properties.py
├── test_additional_response_extra.py
├── test_additional_responses_bad.py
├── test_additional_responses_custom_model_in_callback.py
├── test_additional_responses_custom_validationerror.py
├── test_additional_responses_default_validationerror.py
├── test_additional_responses_response_class.py
├── test_additional_responses_router.py
├── test_application.py
├── test_callable_endpoint.py
├── test_custom_route_class.py
├── test_custom_schema_fields.py
├── test_custom_swagger_ui_redirect.py
├── test_datastructures.py
├── test_datetime_custom_encoder.py
├── test_default_response_class.py
├── test_default_response_class_router.py
├── test_dependency_cache.py
├── test_dependency_class.py
├── test_dependency_contextmanager.py
├── test_dependency_duplicates.py
├── test_dependency_overrides.py
├── test_dependency_security_overrides.py
├── test_deprecated_openapi_prefix.py
├── test_duplicate_models_openapi.py
├── test_empty_router.py
├── test_exception_handlers.py
├── test_extra_routes.py
├── test_filter_pydantic_sub_model.py
├── test_forms_from_non_typing_sequences.py
├── test_get_request_body.py
├── test_http_connection_injection.py
├── test_include_route.py
├── test_include_router_defaults_overrides.py
├── test_infer_param_optionality.py
├── test_inherited_custom_class.py
├── test_invalid_path_param.py
├── test_invalid_sequence_param.py
├── test_jsonable_encoder.py
├── test_local_docs.py
├── test_modules_same_name_body
├── __init__.py
├── app
│ ├── __init__.py
│ ├── a.py
│ ├── b.py
│ └── main.py
└── test_main.py
├── test_multi_body_errors.py
├── test_multi_query_errors.py
├── test_multipart_installation.py
├── test_no_swagger_ui_redirect.py
├── test_openapi_route_extensions.py
├── test_openapi_servers.py
├── test_operations_signatures.py
├── test_param_class.py
├── test_param_in_path_and_dependency.py
├── test_params_repr.py
├── test_path.py
├── test_put_no_body.py
├── test_query.py
├── test_read_with_orm_mode.py
├── test_repeated_cookie_headers.py
├── test_repeated_dependency_schema.py
├── test_request_body_parameters_media_type.py
├── test_response_by_alias.py
├── test_response_change_status_code.py
├── test_response_class_no_mediatype.py
├── test_response_code_no_body.py
├── test_response_model_include_exclude.py
├── test_response_model_invalid.py
├── test_response_model_sub_types.py
├── test_router_events.py
├── test_router_prefix_with_template.py
├── test_schema_extra_examples.py
├── test_security_api_key_cookie.py
├── test_security_api_key_cookie_description.py
├── test_security_api_key_cookie_optional.py
├── test_security_api_key_header.py
├── test_security_api_key_header_description.py
├── test_security_api_key_header_optional.py
├── test_security_api_key_query.py
├── test_security_api_key_query_description.py
├── test_security_api_key_query_optional.py
├── test_security_http_base.py
├── test_security_http_base_description.py
├── test_security_http_base_optional.py
├── test_security_http_basic_optional.py
├── test_security_http_basic_realm.py
├── test_security_http_basic_realm_description.py
├── test_security_http_bearer.py
├── test_security_http_bearer_description.py
├── test_security_http_bearer_optional.py
├── test_security_http_digest.py
├── test_security_http_digest_description.py
├── test_security_http_digest_optional.py
├── test_security_oauth2.py
├── test_security_oauth2_authorization_code_bearer.py
├── test_security_oauth2_authorization_code_bearer_description.py
├── test_security_oauth2_optional.py
├── test_security_oauth2_optional_description.py
├── test_security_oauth2_password_bearer_optional.py
├── test_security_oauth2_password_bearer_optional_description.py
├── test_security_openid_connect.py
├── test_security_openid_connect_description.py
├── test_security_openid_connect_optional.py
├── test_serialize_response.py
├── test_serialize_response_dataclass.py
├── test_serialize_response_model.py
├── test_skip_defaults.py
├── test_starlette_exception.py
├── test_starlette_urlconvertors.py
├── test_sub_callbacks.py
├── test_swagger_ui_init_oauth.py
├── test_tutorial
├── __init__.py
├── test_additional_responses
│ ├── __init__.py
│ ├── test_tutorial001.py
│ ├── test_tutorial002.py
│ ├── test_tutorial003.py
│ └── test_tutorial004.py
├── test_additional_status_codes
│ ├── __init__.py
│ └── test_tutorial001.py
├── test_advanced_middleware
│ ├── __init__.py
│ ├── test_tutorial001.py
│ ├── test_tutorial002.py
│ └── test_tutorial003.py
├── test_async_sql_databases
│ ├── __init__.py
│ └── test_tutorial001.py
├── test_async_tests
│ ├── __init__.py
│ └── test_main.py
├── test_background_tasks
│ ├── __init__.py
│ ├── test_tutorial001.py
│ ├── test_tutorial002.py
│ └── test_tutorial002_py310.py
├── test_behind_a_proxy
│ ├── __init__.py
│ ├── test_tutorial001.py
│ ├── test_tutorial002.py
│ ├── test_tutorial003.py
│ └── test_tutorial004.py
├── test_bigger_applications
│ ├── __init__.py
│ └── test_main.py
├── test_body
│ ├── __init__.py
│ ├── test_tutorial001.py
│ └── test_tutorial001_py310.py
├── test_body_fields
│ ├── __init__.py
│ ├── test_tutorial001.py
│ └── test_tutorial001_py310.py
├── test_body_multiple_params
│ ├── __init__.py
│ ├── test_tutorial001.py
│ ├── test_tutorial001_py310.py
│ ├── test_tutorial003.py
│ └── test_tutorial003_py310.py
├── test_body_nested_models
│ ├── __init__.py
│ ├── test_tutorial009.py
│ └── test_tutorial009_py39.py
├── test_body_updates
│ ├── __init__.py
│ ├── test_tutorial001.py
│ ├── test_tutorial001_py310.py
│ └── test_tutorial001_py39.py
├── test_conditional_openapi
│ ├── __init__.py
│ └── test_tutorial001.py
├── test_cookie_params
│ ├── __init__.py
│ ├── test_tutorial001.py
│ └── test_tutorial001_py310.py
├── test_cors
│ ├── __init__.py
│ └── test_tutorial001.py
├── test_custom_request_and_route
│ ├── __init__.py
│ ├── test_tutorial001.py
│ ├── test_tutorial002.py
│ └── test_tutorial003.py
├── test_custom_response
│ ├── __init__.py
│ ├── test_tutorial001.py
│ ├── test_tutorial001b.py
│ ├── test_tutorial004.py
│ ├── test_tutorial005.py
│ ├── test_tutorial006.py
│ ├── test_tutorial006b.py
│ ├── test_tutorial006c.py
│ ├── test_tutorial007.py
│ ├── test_tutorial008.py
│ ├── test_tutorial009.py
│ └── test_tutorial009b.py
├── test_dataclasses
│ ├── test_tutorial001.py
│ ├── test_tutorial002.py
│ └── test_tutorial003.py
├── test_dependencies
│ ├── __init__.py
│ ├── test_tutorial001.py
│ ├── test_tutorial001_py310.py
│ ├── test_tutorial004.py
│ ├── test_tutorial004_py310.py
│ ├── test_tutorial006.py
│ └── test_tutorial012.py
├── test_events
│ ├── __init__.py
│ ├── test_tutorial001.py
│ └── test_tutorial002.py
├── test_extending_openapi
│ ├── __init__.py
│ ├── test_tutorial001.py
│ └── test_tutorial002.py
├── test_extra_data_types
│ ├── __init__.py
│ ├── test_tutorial001.py
│ └── test_tutorial001_py310.py
├── test_extra_models
│ ├── __init__.py
│ ├── test_tutorial003.py
│ ├── test_tutorial003_py310.py
│ ├── test_tutorial004.py
│ ├── test_tutorial004_py39.py
│ ├── test_tutorial005.py
│ └── test_tutorial005_py39.py
├── test_first_steps
│ ├── __init__.py
│ └── test_tutorial001.py
├── test_handling_errors
│ ├── __init__.py
│ ├── test_tutorial001.py
│ ├── test_tutorial002.py
│ ├── test_tutorial003.py
│ ├── test_tutorial004.py
│ ├── test_tutorial005.py
│ └── test_tutorial006.py
├── test_header_params
│ ├── __init__.py
│ ├── test_tutorial001.py
│ └── test_tutorial001_py310.py
├── test_metadata
│ ├── __init__.py
│ ├── test_tutorial001.py
│ └── test_tutorial004.py
├── test_openapi_callbacks
│ ├── __init__.py
│ └── test_tutorial001.py
├── test_path_operation_advanced_configurations
│ ├── __init__.py
│ ├── test_tutorial001.py
│ ├── test_tutorial002.py
│ ├── test_tutorial003.py
│ ├── test_tutorial004.py
│ ├── test_tutorial005.py
│ ├── test_tutorial006.py
│ └── test_tutorial007.py
├── test_path_operation_configurations
│ ├── __init__.py
│ ├── test_tutorial005.py
│ ├── test_tutorial005_py310.py
│ ├── test_tutorial005_py39.py
│ └── test_tutorial006.py
├── test_path_params
│ ├── __init__.py
│ ├── test_tutorial004.py
│ └── test_tutorial005.py
├── test_query_params
│ ├── __init__.py
│ ├── test_tutorial005.py
│ ├── test_tutorial006.py
│ └── test_tutorial006_py310.py
├── test_query_params_str_validations
│ ├── __init__.py
│ ├── test_tutorial001.py
│ ├── test_tutorial001_py310.py
│ ├── test_tutorial011.py
│ ├── test_tutorial011_py310.py
│ ├── test_tutorial011_py39.py
│ ├── test_tutorial012.py
│ ├── test_tutorial012_py39.py
│ └── test_tutorial013.py
├── test_request_files
│ ├── __init__.py
│ ├── test_tutorial001.py
│ ├── test_tutorial002.py
│ └── test_tutorial002_py39.py
├── test_request_forms
│ ├── __init__.py
│ └── test_tutorial001.py
├── test_request_forms_and_files
│ ├── __init__.py
│ └── test_tutorial001.py
├── test_response_change_status_code
│ ├── __init__.py
│ └── test_tutorial001.py
├── test_response_cookies
│ ├── __init__.py
│ ├── test_tutorial001.py
│ └── test_tutorial002.py
├── test_response_headers
│ ├── __init__.py
│ ├── test_tutorial001.py
│ └── test_tutorial002.py
├── test_response_model
│ ├── __init__.py
│ ├── test_tutorial003.py
│ ├── test_tutorial003_py310.py
│ ├── test_tutorial004.py
│ ├── test_tutorial004_py310.py
│ ├── test_tutorial004_py39.py
│ ├── test_tutorial005.py
│ ├── test_tutorial005_py310.py
│ ├── test_tutorial006.py
│ └── test_tutorial006_py310.py
├── test_schema_extra_example
│ ├── __init__.py
│ ├── test_tutorial004.py
│ └── test_tutorial004_py310.py
├── test_security
│ ├── __init__.py
│ ├── test_tutorial001.py
│ ├── test_tutorial003.py
│ ├── test_tutorial003_py310.py
│ ├── test_tutorial005.py
│ ├── test_tutorial005_py310.py
│ ├── test_tutorial005_py39.py
│ └── test_tutorial006.py
├── test_settings
│ ├── __init__.py
│ └── test_app02.py
├── test_sql_databases
│ ├── __init__.py
│ ├── test_sql_databases.py
│ ├── test_sql_databases_middleware.py
│ ├── test_sql_databases_middleware_py310.py
│ ├── test_sql_databases_middleware_py39.py
│ ├── test_sql_databases_py310.py
│ ├── test_sql_databases_py39.py
│ ├── test_testing_databases.py
│ ├── test_testing_databases_py310.py
│ └── test_testing_databases_py39.py
├── test_sql_databases_peewee
│ ├── __init__.py
│ └── test_sql_databases_peewee.py
├── test_sub_applications
│ ├── __init__.py
│ └── test_tutorial001.py
├── test_templates
│ ├── __init__.py
│ └── test_tutorial001.py
├── test_testing
│ ├── __init__.py
│ ├── test_main.py
│ ├── test_main_b.py
│ ├── test_main_b_py310.py
│ ├── test_tutorial001.py
│ ├── test_tutorial002.py
│ └── test_tutorial003.py
├── test_testing_dependencies
│ ├── __init__.py
│ └── test_tutorial001.py
├── test_websockets
│ ├── __init__.py
│ ├── test_tutorial001.py
│ ├── test_tutorial002.py
│ └── test_tutorial003.py
└── test_wsgi
│ ├── __init__.py
│ └── test_tutorial001.py
├── test_typing_python39.py
├── test_union_body.py
├── test_union_inherited_body.py
├── test_validate_response.py
├── test_validate_response_dataclass.py
├── test_validate_response_recursive.py
├── test_ws_router.py
└── utils.py
/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/.DS_Store
--------------------------------------------------------------------------------
/.flake8:
--------------------------------------------------------------------------------
1 | [flake8]
2 | max-line-length = 88
3 | select = C,E,F,W,B,B9
4 | ignore = E203, E501, W503
5 | exclude = __init__.py
6 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .idea
2 | .ipynb_checkpoints
3 | .mypy_cache
4 | .vscode
5 | __pycache__
6 | .pytest_cache
7 | htmlcov
8 | dist
9 | site
10 | .coverage
11 | coverage.xml
12 | .netlify
13 | test.db
14 | log.txt
15 | Pipfile.lock
16 | env3.*
17 | env
18 | docs_build
19 | venv
20 | docs.zip
21 | archive.zip
22 | .history
23 | .DS_STORE
24 |
25 | # vim temporary files
26 | *~
27 | .*.sw?
28 |
--------------------------------------------------------------------------------
/app/background.py:
--------------------------------------------------------------------------------
1 | from starlette.background import BackgroundTasks as BackgroundTasks # noqa
2 |
--------------------------------------------------------------------------------
/app/dependencies/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/app/dependencies/__init__.py
--------------------------------------------------------------------------------
/app/logger.py:
--------------------------------------------------------------------------------
1 | import logging
2 |
3 | logger = logging.getLogger("fastapi")
4 |
--------------------------------------------------------------------------------
/app/middleware/__init__.py:
--------------------------------------------------------------------------------
1 | from starlette.middleware import Middleware as Middleware
2 |
--------------------------------------------------------------------------------
/app/middleware/cors.py:
--------------------------------------------------------------------------------
1 | from starlette.middleware.cors import CORSMiddleware as CORSMiddleware # noqa
2 |
--------------------------------------------------------------------------------
/app/middleware/gzip.py:
--------------------------------------------------------------------------------
1 | from starlette.middleware.gzip import GZipMiddleware as GZipMiddleware # noqa
2 |
--------------------------------------------------------------------------------
/app/middleware/httpsredirect.py:
--------------------------------------------------------------------------------
1 | from starlette.middleware.httpsredirect import ( # noqa
2 | HTTPSRedirectMiddleware as HTTPSRedirectMiddleware,
3 | )
4 |
--------------------------------------------------------------------------------
/app/middleware/trustedhost.py:
--------------------------------------------------------------------------------
1 | from starlette.middleware.trustedhost import ( # noqa
2 | TrustedHostMiddleware as TrustedHostMiddleware,
3 | )
4 |
--------------------------------------------------------------------------------
/app/middleware/wsgi.py:
--------------------------------------------------------------------------------
1 | from starlette.middleware.wsgi import WSGIMiddleware as WSGIMiddleware # noqa
2 |
--------------------------------------------------------------------------------
/app/openapi/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/app/openapi/__init__.py
--------------------------------------------------------------------------------
/app/openapi/constants.py:
--------------------------------------------------------------------------------
1 | METHODS_WITH_BODY = {"GET", "HEAD", "POST", "PUT", "DELETE", "PATCH"}
2 | STATUS_CODES_WITH_NO_BODY = {100, 101, 102, 103, 204, 304}
3 | REF_PREFIX = "#/components/schemas/"
4 |
--------------------------------------------------------------------------------
/app/py.typed:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/app/py.typed
--------------------------------------------------------------------------------
/app/requests.py:
--------------------------------------------------------------------------------
1 | from starlette.requests import HTTPConnection as HTTPConnection # noqa: F401
2 | from starlette.requests import Request as Request # noqa: F401
3 |
--------------------------------------------------------------------------------
/app/security/base.py:
--------------------------------------------------------------------------------
1 | from fastapi.openapi.models import SecurityBase as SecurityBaseModel
2 |
3 |
4 | class SecurityBase:
5 | model: SecurityBaseModel
6 | scheme_name: str
7 |
--------------------------------------------------------------------------------
/app/security/utils.py:
--------------------------------------------------------------------------------
1 | from typing import Tuple
2 |
3 |
4 | def get_authorization_scheme_param(authorization_header_value: str) -> Tuple[str, str]:
5 | if not authorization_header_value:
6 | return "", ""
7 | scheme, _, param = authorization_header_value.partition(" ")
8 | return scheme, param
9 |
--------------------------------------------------------------------------------
/app/staticfiles.py:
--------------------------------------------------------------------------------
1 | from starlette.staticfiles import StaticFiles as StaticFiles # noqa
2 |
--------------------------------------------------------------------------------
/app/templating.py:
--------------------------------------------------------------------------------
1 | from starlette.templating import Jinja2Templates as Jinja2Templates # noqa
2 |
--------------------------------------------------------------------------------
/app/testclient.py:
--------------------------------------------------------------------------------
1 | from starlette.testclient import TestClient as TestClient # noqa
2 |
--------------------------------------------------------------------------------
/app/types.py:
--------------------------------------------------------------------------------
1 | from typing import Any, Callable, TypeVar
2 |
3 | DecoratedCallable = TypeVar("DecoratedCallable", bound=Callable[..., Any])
4 |
--------------------------------------------------------------------------------
/app/websockets.py:
--------------------------------------------------------------------------------
1 | from starlette.websockets import WebSocket as WebSocket # noqa
2 | from starlette.websockets import WebSocketDisconnect as WebSocketDisconnect # noqa
3 |
--------------------------------------------------------------------------------
/mobile/todo.tx:
--------------------------------------------------------------------------------
1 | add vue ionic
--------------------------------------------------------------------------------
/resources/.eslintignore:
--------------------------------------------------------------------------------
1 | dist
2 | public
3 |
--------------------------------------------------------------------------------
/resources/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "@antfu"
3 | }
4 |
--------------------------------------------------------------------------------
/resources/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | github: antfu
2 |
--------------------------------------------------------------------------------
/resources/.github/ISSUE_TEMPLATE/general.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: General
3 | about: General issue
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | PLEASE READ: I originally made this template for myself to mocking up apps quicker. I am glad to see you are willing to give it a try! Before your open the issue, please make sure you are reporting bugs in the template itself. **I am NOT creating this template to solve the problems you faced in your project, please use Vue or Vite's discord server to ask questions (or it might be closed directly without further notice).** Thank you.
11 |
12 | **Describe the bug/issue**
13 |
--------------------------------------------------------------------------------
/resources/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | .vite-ssg-dist
3 | .vite-ssg-temp
4 | *.local
5 | dist
6 | dist-ssr
7 | node_modules
8 | .idea/
9 | *.log
10 |
--------------------------------------------------------------------------------
/resources/.npmrc:
--------------------------------------------------------------------------------
1 | shamefully-hoist=true
2 |
--------------------------------------------------------------------------------
/resources/cypress.json:
--------------------------------------------------------------------------------
1 | {
2 | "baseUrl": "http://localhost:3333",
3 | "chromeWebSecurity": false
4 | }
5 |
--------------------------------------------------------------------------------
/resources/locales/README.md:
--------------------------------------------------------------------------------
1 | ## i18n
2 |
3 | This directory is to serve your locale translation files. YAML under this folder would be loaded automatically and register with their filenames as locale code.
4 |
5 | Check out [`vue-i18n`](https://github.com/intlify/vue-i18n-next) for more details.
6 |
7 | If you are using VS Code, [`i18n Ally`](https://github.com/lokalise/i18n-ally) is recommended to make the i18n experience better.
8 |
--------------------------------------------------------------------------------
/resources/locales/de.yml:
--------------------------------------------------------------------------------
1 | button:
2 | about: Über
3 | back: Zurück
4 | go: Los
5 | home: Startseite
6 | toggle_dark: Dunkelmodus umschalten
7 | toggle_langs: Sprachen ändern
8 | intro:
9 | desc: Vite Startvorlage mit Vorlieben
10 | dynamic-route: Demo einer dynamischen Route
11 | hi: Hi, {name}!
12 | aka: Auch bekannt als
13 | whats-your-name: Wie heißt du?
14 | not-found: Nicht gefunden
15 |
--------------------------------------------------------------------------------
/resources/locales/en.yml:
--------------------------------------------------------------------------------
1 | button:
2 | about: About
3 | back: Back
4 | go: GO
5 | home: Home
6 | toggle_dark: Toggle dark mode
7 | toggle_langs: Change languages
8 | intro:
9 | desc: Opinionated Vite Starter Template
10 | dynamic-route: Demo of dynamic route
11 | hi: Hi, {name}!
12 | aka: Also known as
13 | whats-your-name: What's your name?
14 | not-found: Not found
15 |
--------------------------------------------------------------------------------
/resources/locales/es.yml:
--------------------------------------------------------------------------------
1 | button:
2 | about: Acerca de
3 | back: Atrás
4 | go: Ir
5 | home: Inicio
6 | toggle_dark: Alternar modo oscuro
7 | toggle_langs: Cambiar idiomas
8 | intro:
9 | desc: Plantilla de Inicio de Vite Dogmática
10 | dynamic-route: Demo de ruta dinámica
11 | hi: ¡Hola, {name}!
12 | aka: También conocido como
13 | whats-your-name: ¿Cómo te llamas?
14 | not-found: No se ha encontrado
15 |
--------------------------------------------------------------------------------
/resources/locales/fr.yml:
--------------------------------------------------------------------------------
1 | button:
2 | about: À propos de
3 | back: Retour
4 | go: Essayer
5 | home: Accueil
6 | toggle_dark: Basculer en mode sombre
7 | toggle_langs: Changer de langue
8 | intro:
9 | desc: Exemple d'application Vite
10 | dynamic-route: Démo de route dynamique
11 | hi: Salut, {name}!
12 | aka: Aussi connu sous le nom de
13 | whats-your-name: Comment t'appelles-tu ?
14 | not-found: Page non trouvée
15 |
--------------------------------------------------------------------------------
/resources/locales/id.yml:
--------------------------------------------------------------------------------
1 | button:
2 | about: Tentang
3 | back: Kembali
4 | go: Pergi
5 | home: Beranda
6 | toggle_dark: Ubah ke mode gelap
7 | toggle_langs: Ubah bahasa
8 | intro:
9 | desc: Template awal vite
10 | dynamic-route: Contoh rute dinamik
11 | hi: Halo, {name}!
12 | aka: Juga diketahui sebagai
13 | whats-your-name: Siapa nama anda?
14 | not-found: Tidak ditemukan
15 |
--------------------------------------------------------------------------------
/resources/locales/it.yml:
--------------------------------------------------------------------------------
1 | button:
2 | about: Su di me
3 | back: Indietro
4 | go: Vai
5 | home: Home
6 | toggle_dark: Attiva/disattiva modalità scura
7 | toggle_langs: Cambia lingua
8 | intro:
9 | desc: Modello per una Applicazione Vite
10 | dynamic-route: Demo di rotta dinamica
11 | hi: Ciao, {name}!
12 | whats-your-name: Come ti chiami?
13 | not-found: Non trovato
14 |
--------------------------------------------------------------------------------
/resources/locales/ja.yml:
--------------------------------------------------------------------------------
1 | button:
2 | about: これは?
3 | back: 戻る
4 | go: 進む
5 | home: ホーム
6 | toggle_dark: ダークモード切り替え
7 | toggle_langs: 言語切り替え
8 | intro:
9 | desc: 固執された Vite スターターテンプレート
10 | dynamic-route: 動的ルートのデモ
11 | hi: こんにちは、{name}!
12 | whats-your-name: 君の名は。
13 | not-found: 見つかりませんでした
14 |
--------------------------------------------------------------------------------
/resources/locales/ko.yml:
--------------------------------------------------------------------------------
1 | button:
2 | about: 소개
3 | back: 뒤로가기
4 | go: 이동
5 | home: 홈
6 | toggle_dark: 다크모드 토글
7 | toggle_langs: 언어 변경
8 | intro:
9 | desc: Vite 애플리케이션 템플릿
10 | dynamic-route: 다이나믹 라우트 데모
11 | hi: 안녕, {name}!
12 | whats-your-name: 이름이 뭐예요?
13 | not-found: 찾을 수 없습니다
14 |
15 |
--------------------------------------------------------------------------------
/resources/locales/pl.yml:
--------------------------------------------------------------------------------
1 | button:
2 | about: O nas
3 | back: Wróć
4 | go: WEJDŹ
5 | home: Strona główna
6 | toggle_dark: Ustaw tryb nocny
7 | toggle_langs: Zmień język
8 | intro:
9 | desc: Opiniowany szablon startowy Vite
10 | dynamic-route: Demonstracja dynamicznego route
11 | hi: Cześć, {name}!
12 | aka: Znany też jako
13 | whats-your-name: Jak masz na imię?
14 | not-found: Nie znaleziono
15 |
--------------------------------------------------------------------------------
/resources/locales/pt-BR.yml:
--------------------------------------------------------------------------------
1 | button:
2 | about: Sobre
3 | back: Voltar
4 | go: Ir
5 | home: Início
6 | toggle_dark: Alternar modo escuro
7 | toggle_langs: Mudar de idioma
8 | intro:
9 | desc: Modelo Opinativo de Partida de Vite
10 | dynamic-route: Demonstração de rota dinâmica
11 | hi: Olá, {name}!
12 | aka: Também conhecido como
13 | whats-your-name: Qual é o seu nome?
14 | not-found: Não encontrado
15 |
--------------------------------------------------------------------------------
/resources/locales/ru.yml:
--------------------------------------------------------------------------------
1 | button:
2 | about: О шаблоне
3 | back: Назад
4 | go: Перейти
5 | home: Главная
6 | toggle_dark: Включить темный режим
7 | toggle_langs: Сменить язык
8 | intro:
9 | desc: Самостоятельный начальный шаблон Vite
10 | dynamic-route: Демо динамического маршрута
11 | hi: Привет, {name}!
12 | whats-your-name: Как тебя зовут?
13 | not-found: Не найден
14 |
--------------------------------------------------------------------------------
/resources/locales/tr.yml:
--------------------------------------------------------------------------------
1 | button:
2 | about: Hakkımda
3 | back: Geri
4 | go: İLERİ
5 | home: Anasayfa
6 | toggle_dark: Karanlık modu değiştir
7 | toggle_langs: Dilleri değiştir
8 | intro:
9 | desc: Görüşlü Vite Başlangıç Şablonu
10 | dynamic-route: Dinamik rota demosu
11 | hi: Merhaba, {name}!
12 | aka: Ayrıca şöyle bilinir
13 | whats-your-name: Adınız nedir?
14 | not-found: Bulunamadı
15 |
--------------------------------------------------------------------------------
/resources/locales/vi.yml:
--------------------------------------------------------------------------------
1 | button:
2 | about: Về
3 | back: Quay lại
4 | go: Đi
5 | home: Khởi đầu
6 | toggle_dark: Chuyển đổi chế độ tối
7 | toggle_langs: Thay đổi ngôn ngữ
8 | intro:
9 | desc: Ý kiến cá nhân Vite Template để bắt đầu
10 | dynamic-route: Bản giới thiệu về dynamic route
11 | hi: Hi, {name}!
12 | whats-your-name: Tên bạn là gì?
13 | not-found: Không tìm thấy
14 |
--------------------------------------------------------------------------------
/resources/locales/zh-CN.yml:
--------------------------------------------------------------------------------
1 | button:
2 | about: 关于
3 | back: 返回
4 | go: 确定
5 | home: 首页
6 | toggle_dark: 切换深色模式
7 | toggle_langs: 切换语言
8 | intro:
9 | desc: 固执己见的 Vite 项目模板
10 | dynamic-route: 动态路由演示
11 | hi: 你好,{name}
12 | aka: 也叫
13 | whats-your-name: 输入你的名字
14 | not-found: 未找到页面
15 |
--------------------------------------------------------------------------------
/resources/netlify.toml:
--------------------------------------------------------------------------------
1 | [build.environment]
2 | # bypass npm auto install
3 | NPM_FLAGS = "--version"
4 | NODE_VERSION = "16"
5 |
6 | [build]
7 | publish = "dist"
8 | command = "npx pnpm i --store=node_modules/.pnpm-store && npx pnpm run build"
9 |
10 | [[redirects]]
11 | from = "/*"
12 | to = "/index.html"
13 | status = 200
14 |
15 | [[headers]]
16 | for = "/manifest.webmanifest"
17 | [headers.values]
18 | Content-Type = "application/manifest+json"
19 |
--------------------------------------------------------------------------------
/resources/public/_headers:
--------------------------------------------------------------------------------
1 | /assets/*
2 | cache-control: max-age=31536000
3 | cache-control: immutable
4 |
--------------------------------------------------------------------------------
/resources/public/favicon.svg:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/resources/public/pwa-192x192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/resources/public/pwa-192x192.png
--------------------------------------------------------------------------------
/resources/public/pwa-512x512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/resources/public/pwa-512x512.png
--------------------------------------------------------------------------------
/resources/public/robots.txt:
--------------------------------------------------------------------------------
1 | User-agent: *
2 | Allow: /
3 |
--------------------------------------------------------------------------------
/resources/src/App.vue:
--------------------------------------------------------------------------------
1 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/resources/src/components.d.ts:
--------------------------------------------------------------------------------
1 | // generated by unplugin-vue-components
2 | // We suggest you to commit this file into source control
3 | // Read more: https://github.com/vuejs/vue-next/pull/3399
4 |
5 | declare module 'vue' {
6 | export interface GlobalComponents {
7 | Counter: typeof import('./components/Counter.vue')['default']
8 | Footer: typeof import('./components/Footer.vue')['default']
9 | README: typeof import('./components/README.md')['default']
10 | }
11 | }
12 |
13 | export { }
14 |
--------------------------------------------------------------------------------
/resources/src/components/Counter.vue:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
11 | {{ count }}
12 |
13 | +
14 |
15 |
16 | -
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/resources/src/components/README.md:
--------------------------------------------------------------------------------
1 | ## Components
2 |
3 | Components in this dir will be auto-registered and on-demand, powered by [`unplugin-vue-components`](https://github.com/antfu/unplugin-vue-components).
4 |
5 |
6 | ### Icons
7 |
8 | You can use icons from almost any icon sets by the power of [Iconify](https://iconify.design/).
9 |
10 | It will only bundle the icons you use. Check out [`unplugin-icons`](https://github.com/antfu/unplugin-icons) for more details.
11 |
--------------------------------------------------------------------------------
/resources/src/composables/dark.ts:
--------------------------------------------------------------------------------
1 | // these APIs are auto-imported from @vueuse/core
2 | export const isDark = useDark()
3 | export const toggleDark = useToggle(isDark)
4 |
--------------------------------------------------------------------------------
/resources/src/composables/index.ts:
--------------------------------------------------------------------------------
1 | export * from './dark'
2 |
--------------------------------------------------------------------------------
/resources/src/layouts/404.vue:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
13 |
14 |
15 |
19 | {{ t('button.back') }}
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/resources/src/layouts/README.md:
--------------------------------------------------------------------------------
1 | ## Layouts
2 |
3 | Vue components in this dir are used as layouts.
4 |
5 | By default, `default.vue` will be used unless an alternative is specified in the route meta.
6 |
7 | With [`vite-plugin-pages`](https://github.com/hannoeru/vite-plugin-pages) and [`vite-plugin-vue-layouts`](https://github.com/JohnCampionJr/vite-plugin-vue-layouts), you can specify the layout in the page's SFCs like this:
8 |
9 | ```html
10 |
11 | meta:
12 | layout: home
13 |
14 | ```
15 |
--------------------------------------------------------------------------------
/resources/src/layouts/default.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | [Default Layout]
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/resources/src/layouts/home.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | [Home Layout]
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/resources/src/modules/README.md:
--------------------------------------------------------------------------------
1 | ## Modules
2 |
3 | A custom user module system. Place a `.ts` file with the following template, it will be installed automatically.
4 |
5 | ```ts
6 | import { UserModule } from '~/types'
7 |
8 | export const install: UserModule = ({ app, router, isClient }) => {
9 | // do something
10 | }
11 | ```
12 |
--------------------------------------------------------------------------------
/resources/src/modules/nprogress.ts:
--------------------------------------------------------------------------------
1 | import NProgress from 'nprogress'
2 | import type { UserModule } from '~/types'
3 |
4 | export const install: UserModule = ({ isClient, router }) => {
5 | if (isClient) {
6 | router.beforeEach(() => { NProgress.start() })
7 | router.afterEach(() => { NProgress.done() })
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/resources/src/modules/pinia.ts:
--------------------------------------------------------------------------------
1 | import { createPinia } from 'pinia'
2 | import type { UserModule } from '~/types'
3 |
4 | // Setup Pinia
5 | // https://pinia.esm.dev/
6 | export const install: UserModule = ({ isClient, initialState, app }) => {
7 | const pinia = createPinia()
8 | app.use(pinia)
9 | // Refer to
10 | // https://github.com/antfu/vite-ssg/blob/main/README.md#state-serialization
11 | // for other serialization strategies.
12 | if (isClient)
13 | pinia.state.value = (initialState.pinia) || {}
14 |
15 | else
16 | initialState.pinia = pinia.state.value
17 | }
18 |
--------------------------------------------------------------------------------
/resources/src/modules/pwa.ts:
--------------------------------------------------------------------------------
1 | import type { UserModule } from '~/types'
2 |
3 | // https://github.com/antfu/vite-plugin-pwa#automatic-reload-when-new-content-available
4 | export const install: UserModule = ({ isClient, router }) => {
5 | if (!isClient)
6 | return
7 |
8 | router.isReady().then(async() => {
9 | const { registerSW } = await import('virtual:pwa-register')
10 | registerSW({ immediate: true })
11 | })
12 | }
13 |
--------------------------------------------------------------------------------
/resources/src/pages/README.md:
--------------------------------------------------------------------------------
1 | ## File-based Routing
2 |
3 | Routes will be auto-generated for Vue files in this dir with the same file structure.
4 | Check out [`vite-plugin-pages`](https://github.com/hannoeru/vite-plugin-pages) for more details.
5 |
6 | ### Path Aliasing
7 |
8 | `~/` is aliased to `./src/` folder.
9 |
10 | For example, instead of having
11 |
12 | ```ts
13 | import { isDark } from '../../../../composables'
14 | ```
15 |
16 | now, you can use
17 |
18 | ```ts
19 | import { isDark } from '~/composables'
20 | ```
21 |
--------------------------------------------------------------------------------
/resources/src/pages/[...all].vue:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 | {{ t('not-found') }}
8 |
9 |
10 |
11 |
12 | meta:
13 | layout: 404
14 |
15 |
--------------------------------------------------------------------------------
/resources/src/shims.d.ts:
--------------------------------------------------------------------------------
1 | declare interface Window {
2 | // extend the window
3 | }
4 |
5 | // with vite-plugin-md, markdowns can be treat as Vue components
6 | declare module '*.md' {
7 | import type { DefineComponent } from 'vue'
8 | const component: DefineComponent<{}, {}, any>
9 | export default component
10 | }
11 |
12 | declare module '*.vue' {
13 | import type { DefineComponent } from 'vue'
14 | const component: DefineComponent<{}, {}, any>
15 | export default component
16 | }
17 |
--------------------------------------------------------------------------------
/resources/src/types.ts:
--------------------------------------------------------------------------------
1 | import type { ViteSSGContext } from 'vite-ssg'
2 |
3 | export type UserModule = (ctx: ViteSSGContext) => void
4 |
--------------------------------------------------------------------------------
/resources/test/__snapshots__/component.test.ts.snap:
--------------------------------------------------------------------------------
1 | // Vitest Snapshot v1
2 |
3 | exports[`Counter.vue > should render 1`] = `"
10 + -
"`;
4 |
--------------------------------------------------------------------------------
/resources/test/basic.test.ts:
--------------------------------------------------------------------------------
1 | describe('tests', () => {
2 | it('should works', () => {
3 | expect(1 + 1).toEqual(2)
4 | })
5 | })
6 |
--------------------------------------------------------------------------------
/resources/todo.tx:
--------------------------------------------------------------------------------
1 | add vue
2 |
3 | best vue mobile frameworks
4 | https://blog.logrocket.com/comparing-vue-js-mobile-app-development-frameworks/
--------------------------------------------------------------------------------
/sugar/.gitignore:
--------------------------------------------------------------------------------
1 | .idea
2 | .ipynb_checkpoints
3 | .mypy_cache
4 | .vscode
5 | __pycache__
6 | .pytest_cache
7 | htmlcov
8 | dist
9 | site
10 | .coverage
11 | coverage.xml
12 | .netlify
13 | test.db
14 | log.txt
15 | Pipfile.lock
16 | env3.*
17 | env
18 | docs_build
19 | venv
20 | docs.zip
21 | archive.zip
22 | .history
23 | .DS_STORE
24 |
25 | # vim temporary files
26 | *~
27 | .*.sw?
28 |
--------------------------------------------------------------------------------
/sugar/docs/az/overrides/.gitignore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/az/overrides/.gitignore
--------------------------------------------------------------------------------
/sugar/docs/de/overrides/.gitignore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/de/overrides/.gitignore
--------------------------------------------------------------------------------
/sugar/docs/en/data/sponsors_badge.yml:
--------------------------------------------------------------------------------
1 | logins:
2 | - jina-ai
3 | - deta
4 | - investsuite
5 | - vimsoHQ
6 | - mikeckennedy
7 | - koaning
8 | - deepset-ai
9 | - cryptapi
10 |
--------------------------------------------------------------------------------
/sugar/docs/en/docs/advanced/testing-events.md:
--------------------------------------------------------------------------------
1 | # Testing Events: startup - shutdown
2 |
3 | When you need your event handlers (`startup` and `shutdown`) to run in your tests, you can use the `TestClient` with a `with` statement:
4 |
5 | ```Python hl_lines="9-12 20-24"
6 | {!../../../docs_src/app_testing/tutorial003.py!}
7 | ```
8 |
--------------------------------------------------------------------------------
/sugar/docs/en/docs/advanced/testing-websockets.md:
--------------------------------------------------------------------------------
1 | # Testing WebSockets
2 |
3 | You can use the same `TestClient` to test WebSockets.
4 |
5 | For this, you use the `TestClient` in a `with` statement, connecting to the WebSocket:
6 |
7 | ```Python hl_lines="27-31"
8 | {!../../../docs_src/app_testing/tutorial002.py!}
9 | ```
10 |
11 | !!! note
12 | For more details, check Starlette's documentation for testing WebSockets .
13 |
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/deployment/concepts/image01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/deployment/concepts/image01.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/deployment/deta/image01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/deployment/deta/image01.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/deployment/deta/image02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/deployment/deta/image02.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/favicon.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/github-social-preview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/github-social-preview.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/icon-transparent-bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/icon-transparent-bg.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/icon-white-bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/icon-white-bg.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/index/index-01-swagger-ui-simple.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/index/index-01-swagger-ui-simple.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/index/index-02-redoc-simple.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/index/index-02-redoc-simple.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/index/index-03-swagger-02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/index/index-03-swagger-02.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/index/index-04-swagger-03.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/index/index-04-swagger-03.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/index/index-05-swagger-04.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/index/index-05-swagger-04.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/index/index-06-redoc-02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/index/index-06-redoc-02.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/logo-margin/logo-teal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/logo-margin/logo-teal.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/logo-margin/logo-white-bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/logo-margin/logo-white-bg.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/pycharm-completion.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/pycharm-completion.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/python-types/image01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/python-types/image01.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/python-types/image02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/python-types/image02.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/python-types/image03.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/python-types/image03.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/python-types/image04.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/python-types/image04.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/python-types/image05.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/python-types/image05.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/python-types/image06.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/python-types/image06.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/sponsors/calmcode.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/sponsors/calmcode.jpg
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/sponsors/talkpython.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/sponsors/talkpython.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/sponsors/vimso.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/sponsors/vimso.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/additional-responses/image01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/additional-responses/image01.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/async-sql-databases/image01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/async-sql-databases/image01.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/behind-a-proxy/image01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/behind-a-proxy/image01.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/behind-a-proxy/image02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/behind-a-proxy/image02.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/behind-a-proxy/image03.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/behind-a-proxy/image03.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/bigger-applications/image01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/bigger-applications/image01.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/body-fields/image01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/body-fields/image01.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/body-fields/image02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/body-fields/image02.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/body-nested-models/image01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/body-nested-models/image01.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/body/image01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/body/image01.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/body/image02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/body/image02.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/body/image03.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/body/image03.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/body/image04.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/body/image04.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/body/image05.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/body/image05.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/custom-response/image01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/custom-response/image01.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/dataclasses/image01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/dataclasses/image01.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/debugging/image01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/debugging/image01.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/debugging/image02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/debugging/image02.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/dependencies/image01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/dependencies/image01.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/dependencies/image02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/dependencies/image02.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/extending-openapi/image01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/extending-openapi/image01.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/graphql/image01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/graphql/image01.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/metadata/image01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/metadata/image01.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/metadata/image02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/metadata/image02.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/openapi-callbacks/image01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/openapi-callbacks/image01.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/path-operation-advanced-configuration/image01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/path-operation-advanced-configuration/image01.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/path-operation-configuration/image01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/path-operation-configuration/image01.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/path-operation-configuration/image02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/path-operation-configuration/image02.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/path-operation-configuration/image03.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/path-operation-configuration/image03.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/path-operation-configuration/image04.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/path-operation-configuration/image04.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/path-operation-configuration/image05.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/path-operation-configuration/image05.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/path-params/image01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/path-params/image01.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/path-params/image02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/path-params/image02.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/path-params/image03.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/path-params/image03.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/query-params-str-validations/image01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/query-params-str-validations/image01.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/query-params-str-validations/image02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/query-params-str-validations/image02.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/response-model/image01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/response-model/image01.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/response-model/image02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/response-model/image02.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/response-status-code/image01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/response-status-code/image01.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/response-status-code/image02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/response-status-code/image02.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/security/image01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/security/image01.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/security/image02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/security/image02.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/security/image03.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/security/image03.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/security/image04.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/security/image04.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/security/image05.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/security/image05.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/security/image06.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/security/image06.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/security/image07.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/security/image07.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/security/image08.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/security/image08.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/security/image09.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/security/image09.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/security/image10.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/security/image10.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/security/image11.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/security/image11.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/security/image12.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/security/image12.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/sql-databases/image01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/sql-databases/image01.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/sql-databases/image02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/sql-databases/image02.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/sub-applications/image01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/sub-applications/image01.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/sub-applications/image02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/sub-applications/image02.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/websockets/image01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/websockets/image01.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/websockets/image02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/websockets/image02.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/websockets/image03.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/websockets/image03.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/websockets/image04.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/websockets/image04.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/tutorial/websockets/image05.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/tutorial/websockets/image05.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/img/vscode-completion.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/en/docs/img/vscode-completion.png
--------------------------------------------------------------------------------
/sugar/docs/en/docs/js/chat.js:
--------------------------------------------------------------------------------
1 | ((window.gitter = {}).chat = {}).options = {
2 | room: 'tiangolo/fastapi'
3 | };
4 |
--------------------------------------------------------------------------------
/sugar/docs/en/docs/newsletter.md:
--------------------------------------------------------------------------------
1 | # FastAPI and friends newsletter
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/sugar/docs/es/overrides/.gitignore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/es/overrides/.gitignore
--------------------------------------------------------------------------------
/sugar/docs/fr/overrides/.gitignore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/fr/overrides/.gitignore
--------------------------------------------------------------------------------
/sugar/docs/id/overrides/.gitignore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/id/overrides/.gitignore
--------------------------------------------------------------------------------
/sugar/docs/it/overrides/.gitignore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/it/overrides/.gitignore
--------------------------------------------------------------------------------
/sugar/docs/ja/docs/deployment/index.md:
--------------------------------------------------------------------------------
1 | # デプロイ - イントロ
2 |
3 | **FastAPI** 製のアプリケーションは比較的容易にデプロイできます。
4 |
5 | ユースケースや使用しているツールによっていくつかの方法に分かれます。
6 |
7 | 次のセクションでより詳しくそれらの方法について説明します。
--------------------------------------------------------------------------------
/sugar/docs/ja/overrides/.gitignore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/ja/overrides/.gitignore
--------------------------------------------------------------------------------
/sugar/docs/ko/overrides/.gitignore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/ko/overrides/.gitignore
--------------------------------------------------------------------------------
/sugar/docs/missing-translation.md:
--------------------------------------------------------------------------------
1 | !!! warning
2 | The current page still doesn't have a translation for this language.
3 |
4 | But you can help translating it: [Contributing](https://fastapi.tiangolo.com/contributing/){.internal-link target=_blank}.
5 |
--------------------------------------------------------------------------------
/sugar/docs/pl/overrides/.gitignore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/pl/overrides/.gitignore
--------------------------------------------------------------------------------
/sugar/docs/pt/docs/deployment/index.md:
--------------------------------------------------------------------------------
1 | # Implantação - Introdução
2 |
3 | A implantação de uma aplicação **FastAPI** é relativamente simples.
4 |
5 | Existem várias maneiras para fazer isso, dependendo do seu caso específico e das ferramentas que você utiliza.
6 |
7 | Você verá mais detalhes para se ter em mente e algumas das técnicas para a implantação nas próximas seções.
8 |
--------------------------------------------------------------------------------
/sugar/docs/pt/overrides/.gitignore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/pt/overrides/.gitignore
--------------------------------------------------------------------------------
/sugar/docs/ru/overrides/.gitignore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/ru/overrides/.gitignore
--------------------------------------------------------------------------------
/sugar/docs/sq/overrides/.gitignore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/sq/overrides/.gitignore
--------------------------------------------------------------------------------
/sugar/docs/tr/overrides/.gitignore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/tr/overrides/.gitignore
--------------------------------------------------------------------------------
/sugar/docs/uk/overrides/.gitignore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/uk/overrides/.gitignore
--------------------------------------------------------------------------------
/sugar/docs/zh/docs/advanced/index.md:
--------------------------------------------------------------------------------
1 | # 高级用户指南 - 简介
2 |
3 | ## 额外特性
4 |
5 | 主要的教程 [教程 - 用户指南](../tutorial/){.internal-link target=_blank} 应该足以让你了解 **FastAPI** 的所有主要特性。
6 |
7 | 你会在接下来的章节中了解到其他的选项、配置以及额外的特性。
8 |
9 | !!! tip
10 | 接下来的章节**并不一定是**「高级的」。
11 |
12 | 而且对于你的使用场景来说,解决方案很可能就在其中。
13 |
14 | ## 先阅读教程
15 |
16 | 你可能仍会用到 **FastAPI** 主教程 [教程 - 用户指南](../tutorial/){.internal-link target=_blank} 中的大多数特性。
17 |
18 | 接下来的章节我们认为你已经读过 [教程 - 用户指南](../tutorial/){.internal-link target=_blank},并且假设你已经知晓其中主要思想。
19 |
--------------------------------------------------------------------------------
/sugar/docs/zh/overrides/.gitignore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs/zh/overrides/.gitignore
--------------------------------------------------------------------------------
/sugar/docs_src/advanced_middleware/tutorial001.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 | from fastapi.middleware.httpsredirect import HTTPSRedirectMiddleware
3 |
4 | app = FastAPI()
5 |
6 | app.add_middleware(HTTPSRedirectMiddleware)
7 |
8 |
9 | @app.get("/")
10 | async def main():
11 | return {"message": "Hello World"}
12 |
--------------------------------------------------------------------------------
/sugar/docs_src/advanced_middleware/tutorial002.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 | from fastapi.middleware.trustedhost import TrustedHostMiddleware
3 |
4 | app = FastAPI()
5 |
6 | app.add_middleware(
7 | TrustedHostMiddleware, allowed_hosts=["example.com", "*.example.com"]
8 | )
9 |
10 |
11 | @app.get("/")
12 | async def main():
13 | return {"message": "Hello World"}
14 |
--------------------------------------------------------------------------------
/sugar/docs_src/advanced_middleware/tutorial003.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 | from fastapi.middleware.gzip import GZipMiddleware
3 |
4 | app = FastAPI()
5 |
6 | app.add_middleware(GZipMiddleware, minimum_size=1000)
7 |
8 |
9 | @app.get("/")
10 | async def main():
11 | return "somebigcontent"
12 |
--------------------------------------------------------------------------------
/sugar/docs_src/app_testing/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs_src/app_testing/__init__.py
--------------------------------------------------------------------------------
/sugar/docs_src/app_testing/app_b/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs_src/app_testing/app_b/__init__.py
--------------------------------------------------------------------------------
/sugar/docs_src/app_testing/app_b_py310/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs_src/app_testing/app_b_py310/__init__.py
--------------------------------------------------------------------------------
/sugar/docs_src/app_testing/main.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 |
3 | app = FastAPI()
4 |
5 |
6 | @app.get("/")
7 | async def read_main():
8 | return {"msg": "Hello World"}
9 |
--------------------------------------------------------------------------------
/sugar/docs_src/app_testing/test_main.py:
--------------------------------------------------------------------------------
1 | from fastapi.testclient import TestClient
2 |
3 | from .main import app
4 |
5 | client = TestClient(app)
6 |
7 |
8 | def test_read_main():
9 | response = client.get("/")
10 | assert response.status_code == 200
11 | assert response.json() == {"msg": "Hello World"}
12 |
--------------------------------------------------------------------------------
/sugar/docs_src/app_testing/tutorial001.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 | from fastapi.testclient import TestClient
3 |
4 | app = FastAPI()
5 |
6 |
7 | @app.get("/")
8 | async def read_main():
9 | return {"msg": "Hello World"}
10 |
11 |
12 | client = TestClient(app)
13 |
14 |
15 | def test_read_main():
16 | response = client.get("/")
17 | assert response.status_code == 200
18 | assert response.json() == {"msg": "Hello World"}
19 |
--------------------------------------------------------------------------------
/sugar/docs_src/async_tests/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs_src/async_tests/__init__.py
--------------------------------------------------------------------------------
/sugar/docs_src/async_tests/main.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 |
3 | app = FastAPI()
4 |
5 |
6 | @app.get("/")
7 | async def root():
8 | return {"message": "Tomato"}
9 |
--------------------------------------------------------------------------------
/sugar/docs_src/async_tests/test_main.py:
--------------------------------------------------------------------------------
1 | import pytest
2 | from httpx import AsyncClient
3 |
4 | from .main import app
5 |
6 |
7 | @pytest.mark.anyio
8 | async def test_root():
9 | async with AsyncClient(app=app, base_url="http://test") as ac:
10 | response = await ac.get("/")
11 | assert response.status_code == 200
12 | assert response.json() == {"message": "Tomato"}
13 |
--------------------------------------------------------------------------------
/sugar/docs_src/background_tasks/tutorial001.py:
--------------------------------------------------------------------------------
1 | from fastapi import BackgroundTasks, FastAPI
2 |
3 | app = FastAPI()
4 |
5 |
6 | def write_notification(email: str, message=""):
7 | with open("log.txt", mode="w") as email_file:
8 | content = f"notification for {email}: {message}"
9 | email_file.write(content)
10 |
11 |
12 | @app.post("/send-notification/{email}")
13 | async def send_notification(email: str, background_tasks: BackgroundTasks):
14 | background_tasks.add_task(write_notification, email, message="some notification")
15 | return {"message": "Notification sent in the background"}
16 |
--------------------------------------------------------------------------------
/sugar/docs_src/behind_a_proxy/tutorial001.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI, Request
2 |
3 | app = FastAPI()
4 |
5 |
6 | @app.get("/app")
7 | def read_main(request: Request):
8 | return {"message": "Hello World", "root_path": request.scope.get("root_path")}
9 |
--------------------------------------------------------------------------------
/sugar/docs_src/behind_a_proxy/tutorial002.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI, Request
2 |
3 | app = FastAPI(root_path="/api/v1")
4 |
5 |
6 | @app.get("/app")
7 | def read_main(request: Request):
8 | return {"message": "Hello World", "root_path": request.scope.get("root_path")}
9 |
--------------------------------------------------------------------------------
/sugar/docs_src/behind_a_proxy/tutorial003.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI, Request
2 |
3 | app = FastAPI(
4 | servers=[
5 | {"url": "https://stag.example.com", "description": "Staging environment"},
6 | {"url": "https://prod.example.com", "description": "Production environment"},
7 | ],
8 | root_path="/api/v1",
9 | )
10 |
11 |
12 | @app.get("/app")
13 | def read_main(request: Request):
14 | return {"message": "Hello World", "root_path": request.scope.get("root_path")}
15 |
--------------------------------------------------------------------------------
/sugar/docs_src/behind_a_proxy/tutorial004.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI, Request
2 |
3 | app = FastAPI(
4 | servers=[
5 | {"url": "https://stag.example.com", "description": "Staging environment"},
6 | {"url": "https://prod.example.com", "description": "Production environment"},
7 | ],
8 | root_path="/api/v1",
9 | root_path_in_servers=False,
10 | )
11 |
12 |
13 | @app.get("/app")
14 | def read_main(request: Request):
15 | return {"message": "Hello World", "root_path": request.scope.get("root_path")}
16 |
--------------------------------------------------------------------------------
/sugar/docs_src/bigger_applications/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs_src/bigger_applications/__init__.py
--------------------------------------------------------------------------------
/sugar/docs_src/bigger_applications/app/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs_src/bigger_applications/app/__init__.py
--------------------------------------------------------------------------------
/sugar/docs_src/bigger_applications/app/dependencies.py:
--------------------------------------------------------------------------------
1 | from fastapi import Header, HTTPException
2 |
3 |
4 | async def get_token_header(x_token: str = Header(...)):
5 | if x_token != "fake-super-secret-token":
6 | raise HTTPException(status_code=400, detail="X-Token header invalid")
7 |
8 |
9 | async def get_query_token(token: str):
10 | if token != "jessica":
11 | raise HTTPException(status_code=400, detail="No Jessica token provided")
12 |
--------------------------------------------------------------------------------
/sugar/docs_src/bigger_applications/app/internal/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs_src/bigger_applications/app/internal/__init__.py
--------------------------------------------------------------------------------
/sugar/docs_src/bigger_applications/app/internal/admin.py:
--------------------------------------------------------------------------------
1 | from fastapi import APIRouter
2 |
3 | router = APIRouter()
4 |
5 |
6 | @router.post("/")
7 | async def update_admin():
8 | return {"message": "Admin getting schwifty"}
9 |
--------------------------------------------------------------------------------
/sugar/docs_src/bigger_applications/app/routers/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs_src/bigger_applications/app/routers/__init__.py
--------------------------------------------------------------------------------
/sugar/docs_src/bigger_applications/app/routers/users.py:
--------------------------------------------------------------------------------
1 | from fastapi import APIRouter
2 |
3 | router = APIRouter()
4 |
5 |
6 | @router.get("/users/", tags=["users"])
7 | async def read_users():
8 | return [{"username": "Rick"}, {"username": "Morty"}]
9 |
10 |
11 | @router.get("/users/me", tags=["users"])
12 | async def read_user_me():
13 | return {"username": "fakecurrentuser"}
14 |
15 |
16 | @router.get("/users/{username}", tags=["users"])
17 | async def read_user(username: str):
18 | return {"username": username}
19 |
--------------------------------------------------------------------------------
/sugar/docs_src/body/tutorial001.py:
--------------------------------------------------------------------------------
1 | from typing import Optional
2 |
3 | from fastapi import FastAPI
4 | from pydantic import BaseModel
5 |
6 |
7 | class Item(BaseModel):
8 | name: str
9 | description: Optional[str] = None
10 | price: float
11 | tax: Optional[float] = None
12 |
13 |
14 | app = FastAPI()
15 |
16 |
17 | @app.post("/items/")
18 | async def create_item(item: Item):
19 | return item
20 |
--------------------------------------------------------------------------------
/sugar/docs_src/body/tutorial001_py310.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 | from pydantic import BaseModel
3 |
4 |
5 | class Item(BaseModel):
6 | name: str
7 | description: str | None = None
8 | price: float
9 | tax: float | None = None
10 |
11 |
12 | app = FastAPI()
13 |
14 |
15 | @app.post("/items/")
16 | async def create_item(item: Item):
17 | return item
18 |
--------------------------------------------------------------------------------
/sugar/docs_src/body/tutorial002.py:
--------------------------------------------------------------------------------
1 | from typing import Optional
2 |
3 | from fastapi import FastAPI
4 | from pydantic import BaseModel
5 |
6 |
7 | class Item(BaseModel):
8 | name: str
9 | description: Optional[str] = None
10 | price: float
11 | tax: Optional[float] = None
12 |
13 |
14 | app = FastAPI()
15 |
16 |
17 | @app.post("/items/")
18 | async def create_item(item: Item):
19 | item_dict = item.dict()
20 | if item.tax:
21 | price_with_tax = item.price + item.tax
22 | item_dict.update({"price_with_tax": price_with_tax})
23 | return item_dict
24 |
--------------------------------------------------------------------------------
/sugar/docs_src/body/tutorial002_py310.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 | from pydantic import BaseModel
3 |
4 |
5 | class Item(BaseModel):
6 | name: str
7 | description: str | None = None
8 | price: float
9 | tax: float | None = None
10 |
11 |
12 | app = FastAPI()
13 |
14 |
15 | @app.post("/items/")
16 | async def create_item(item: Item):
17 | item_dict = item.dict()
18 | if item.tax:
19 | price_with_tax = item.price + item.tax
20 | item_dict.update({"price_with_tax": price_with_tax})
21 | return item_dict
22 |
--------------------------------------------------------------------------------
/sugar/docs_src/body/tutorial003.py:
--------------------------------------------------------------------------------
1 | from typing import Optional
2 |
3 | from fastapi import FastAPI
4 | from pydantic import BaseModel
5 |
6 |
7 | class Item(BaseModel):
8 | name: str
9 | description: Optional[str] = None
10 | price: float
11 | tax: Optional[float] = None
12 |
13 |
14 | app = FastAPI()
15 |
16 |
17 | @app.put("/items/{item_id}")
18 | async def create_item(item_id: int, item: Item):
19 | return {"item_id": item_id, **item.dict()}
20 |
--------------------------------------------------------------------------------
/sugar/docs_src/body/tutorial003_py310.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 | from pydantic import BaseModel
3 |
4 |
5 | class Item(BaseModel):
6 | name: str
7 | description: str | None = None
8 | price: float
9 | tax: float | None = None
10 |
11 |
12 | app = FastAPI()
13 |
14 |
15 | @app.put("/items/{item_id}")
16 | async def create_item(item_id: int, item: Item):
17 | return {"item_id": item_id, **item.dict()}
18 |
--------------------------------------------------------------------------------
/sugar/docs_src/body/tutorial004.py:
--------------------------------------------------------------------------------
1 | from typing import Optional
2 |
3 | from fastapi import FastAPI
4 | from pydantic import BaseModel
5 |
6 |
7 | class Item(BaseModel):
8 | name: str
9 | description: Optional[str] = None
10 | price: float
11 | tax: Optional[float] = None
12 |
13 |
14 | app = FastAPI()
15 |
16 |
17 | @app.put("/items/{item_id}")
18 | async def create_item(item_id: int, item: Item, q: Optional[str] = None):
19 | result = {"item_id": item_id, **item.dict()}
20 | if q:
21 | result.update({"q": q})
22 | return result
23 |
--------------------------------------------------------------------------------
/sugar/docs_src/body/tutorial004_py310.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 | from pydantic import BaseModel
3 |
4 |
5 | class Item(BaseModel):
6 | name: str
7 | description: str | None = None
8 | price: float
9 | tax: float | None = None
10 |
11 |
12 | app = FastAPI()
13 |
14 |
15 | @app.put("/items/{item_id}")
16 | async def create_item(item_id: int, item: Item, q: str | None = None):
17 | result = {"item_id": item_id, **item.dict()}
18 | if q:
19 | result.update({"q": q})
20 | return result
21 |
--------------------------------------------------------------------------------
/sugar/docs_src/body_fields/tutorial001_py310.py:
--------------------------------------------------------------------------------
1 | from fastapi import Body, FastAPI
2 | from pydantic import BaseModel, Field
3 |
4 | app = FastAPI()
5 |
6 |
7 | class Item(BaseModel):
8 | name: str
9 | description: str | None = Field(
10 | None, title="The description of the item", max_length=300
11 | )
12 | price: float = Field(..., gt=0, description="The price must be greater than zero")
13 | tax: float | None = None
14 |
15 |
16 | @app.put("/items/{item_id}")
17 | async def update_item(item_id: int, item: Item = Body(..., embed=True)):
18 | results = {"item_id": item_id, "item": item}
19 | return results
20 |
--------------------------------------------------------------------------------
/sugar/docs_src/body_multiple_params/tutorial002.py:
--------------------------------------------------------------------------------
1 | from typing import Optional
2 |
3 | from fastapi import FastAPI
4 | from pydantic import BaseModel
5 |
6 | app = FastAPI()
7 |
8 |
9 | class Item(BaseModel):
10 | name: str
11 | description: Optional[str] = None
12 | price: float
13 | tax: Optional[float] = None
14 |
15 |
16 | class User(BaseModel):
17 | username: str
18 | full_name: Optional[str] = None
19 |
20 |
21 | @app.put("/items/{item_id}")
22 | async def update_item(item_id: int, item: Item, user: User):
23 | results = {"item_id": item_id, "item": item, "user": user}
24 | return results
25 |
--------------------------------------------------------------------------------
/sugar/docs_src/body_multiple_params/tutorial002_py310.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 | from pydantic import BaseModel
3 |
4 | app = FastAPI()
5 |
6 |
7 | class Item(BaseModel):
8 | name: str
9 | description: str | None = None
10 | price: float
11 | tax: float | None = None
12 |
13 |
14 | class User(BaseModel):
15 | username: str
16 | full_name: str | None = None
17 |
18 |
19 | @app.put("/items/{item_id}")
20 | async def update_item(item_id: int, item: Item, user: User):
21 | results = {"item_id": item_id, "item": item, "user": user}
22 | return results
23 |
--------------------------------------------------------------------------------
/sugar/docs_src/body_multiple_params/tutorial005.py:
--------------------------------------------------------------------------------
1 | from typing import Optional
2 |
3 | from fastapi import Body, FastAPI
4 | from pydantic import BaseModel
5 |
6 | app = FastAPI()
7 |
8 |
9 | class Item(BaseModel):
10 | name: str
11 | description: Optional[str] = None
12 | price: float
13 | tax: Optional[float] = None
14 |
15 |
16 | @app.put("/items/{item_id}")
17 | async def update_item(item_id: int, item: Item = Body(..., embed=True)):
18 | results = {"item_id": item_id, "item": item}
19 | return results
20 |
--------------------------------------------------------------------------------
/sugar/docs_src/body_multiple_params/tutorial005_py310.py:
--------------------------------------------------------------------------------
1 | from fastapi import Body, FastAPI
2 | from pydantic import BaseModel
3 |
4 | app = FastAPI()
5 |
6 |
7 | class Item(BaseModel):
8 | name: str
9 | description: str | None = None
10 | price: float
11 | tax: float | None = None
12 |
13 |
14 | @app.put("/items/{item_id}")
15 | async def update_item(item_id: int, item: Item = Body(..., embed=True)):
16 | results = {"item_id": item_id, "item": item}
17 | return results
18 |
--------------------------------------------------------------------------------
/sugar/docs_src/body_nested_models/tutorial001.py:
--------------------------------------------------------------------------------
1 | from typing import Optional
2 |
3 | from fastapi import FastAPI
4 | from pydantic import BaseModel
5 |
6 | app = FastAPI()
7 |
8 |
9 | class Item(BaseModel):
10 | name: str
11 | description: Optional[str] = None
12 | price: float
13 | tax: Optional[float] = None
14 | tags: list = []
15 |
16 |
17 | @app.put("/items/{item_id}")
18 | async def update_item(item_id: int, item: Item):
19 | results = {"item_id": item_id, "item": item}
20 | return results
21 |
--------------------------------------------------------------------------------
/sugar/docs_src/body_nested_models/tutorial001_py310.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 | from pydantic import BaseModel
3 |
4 | app = FastAPI()
5 |
6 |
7 | class Item(BaseModel):
8 | name: str
9 | description: str | None = None
10 | price: float
11 | tax: float | None = None
12 | tags: list = []
13 |
14 |
15 | @app.put("/items/{item_id}")
16 | async def update_item(item_id: int, item: Item):
17 | results = {"item_id": item_id, "item": item}
18 | return results
19 |
--------------------------------------------------------------------------------
/sugar/docs_src/body_nested_models/tutorial002.py:
--------------------------------------------------------------------------------
1 | from typing import List, Optional
2 |
3 | from fastapi import FastAPI
4 | from pydantic import BaseModel
5 |
6 | app = FastAPI()
7 |
8 |
9 | class Item(BaseModel):
10 | name: str
11 | description: Optional[str] = None
12 | price: float
13 | tax: Optional[float] = None
14 | tags: List[str] = []
15 |
16 |
17 | @app.put("/items/{item_id}")
18 | async def update_item(item_id: int, item: Item):
19 | results = {"item_id": item_id, "item": item}
20 | return results
21 |
--------------------------------------------------------------------------------
/sugar/docs_src/body_nested_models/tutorial002_py310.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 | from pydantic import BaseModel
3 |
4 | app = FastAPI()
5 |
6 |
7 | class Item(BaseModel):
8 | name: str
9 | description: str | None = None
10 | price: float
11 | tax: float | None = None
12 | tags: list[str] = []
13 |
14 |
15 | @app.put("/items/{item_id}")
16 | async def update_item(item_id: int, item: Item):
17 | results = {"item_id": item_id, "item": item}
18 | return results
19 |
--------------------------------------------------------------------------------
/sugar/docs_src/body_nested_models/tutorial002_py39.py:
--------------------------------------------------------------------------------
1 | from typing import Optional
2 |
3 | from fastapi import FastAPI
4 | from pydantic import BaseModel
5 |
6 | app = FastAPI()
7 |
8 |
9 | class Item(BaseModel):
10 | name: str
11 | description: Optional[str] = None
12 | price: float
13 | tax: Optional[float] = None
14 | tags: list[str] = []
15 |
16 |
17 | @app.put("/items/{item_id}")
18 | async def update_item(item_id: int, item: Item):
19 | results = {"item_id": item_id, "item": item}
20 | return results
21 |
--------------------------------------------------------------------------------
/sugar/docs_src/body_nested_models/tutorial003.py:
--------------------------------------------------------------------------------
1 | from typing import Optional, Set
2 |
3 | from fastapi import FastAPI
4 | from pydantic import BaseModel
5 |
6 | app = FastAPI()
7 |
8 |
9 | class Item(BaseModel):
10 | name: str
11 | description: Optional[str] = None
12 | price: float
13 | tax: Optional[float] = None
14 | tags: Set[str] = set()
15 |
16 |
17 | @app.put("/items/{item_id}")
18 | async def update_item(item_id: int, item: Item):
19 | results = {"item_id": item_id, "item": item}
20 | return results
21 |
--------------------------------------------------------------------------------
/sugar/docs_src/body_nested_models/tutorial003_py310.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 | from pydantic import BaseModel
3 |
4 | app = FastAPI()
5 |
6 |
7 | class Item(BaseModel):
8 | name: str
9 | description: str | None = None
10 | price: float
11 | tax: float | None = None
12 | tags: set[str] = set()
13 |
14 |
15 | @app.put("/items/{item_id}")
16 | async def update_item(item_id: int, item: Item):
17 | results = {"item_id": item_id, "item": item}
18 | return results
19 |
--------------------------------------------------------------------------------
/sugar/docs_src/body_nested_models/tutorial003_py39.py:
--------------------------------------------------------------------------------
1 | from typing import Optional
2 |
3 | from fastapi import FastAPI
4 | from pydantic import BaseModel
5 |
6 | app = FastAPI()
7 |
8 |
9 | class Item(BaseModel):
10 | name: str
11 | description: Optional[str] = None
12 | price: float
13 | tax: Optional[float] = None
14 | tags: set[str] = set()
15 |
16 |
17 | @app.put("/items/{item_id}")
18 | async def update_item(item_id: int, item: Item):
19 | results = {"item_id": item_id, "item": item}
20 | return results
21 |
--------------------------------------------------------------------------------
/sugar/docs_src/body_nested_models/tutorial004.py:
--------------------------------------------------------------------------------
1 | from typing import Optional, Set
2 |
3 | from fastapi import FastAPI
4 | from pydantic import BaseModel
5 |
6 | app = FastAPI()
7 |
8 |
9 | class Image(BaseModel):
10 | url: str
11 | name: str
12 |
13 |
14 | class Item(BaseModel):
15 | name: str
16 | description: Optional[str] = None
17 | price: float
18 | tax: Optional[float] = None
19 | tags: Set[str] = []
20 | image: Optional[Image] = None
21 |
22 |
23 | @app.put("/items/{item_id}")
24 | async def update_item(item_id: int, item: Item):
25 | results = {"item_id": item_id, "item": item}
26 | return results
27 |
--------------------------------------------------------------------------------
/sugar/docs_src/body_nested_models/tutorial004_py310.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 | from pydantic import BaseModel
3 |
4 | app = FastAPI()
5 |
6 |
7 | class Image(BaseModel):
8 | url: str
9 | name: str
10 |
11 |
12 | class Item(BaseModel):
13 | name: str
14 | description: str | None = None
15 | price: float
16 | tax: float | None = None
17 | tags: set[str] = []
18 | image: Image | None = None
19 |
20 |
21 | @app.put("/items/{item_id}")
22 | async def update_item(item_id: int, item: Item):
23 | results = {"item_id": item_id, "item": item}
24 | return results
25 |
--------------------------------------------------------------------------------
/sugar/docs_src/body_nested_models/tutorial004_py39.py:
--------------------------------------------------------------------------------
1 | from typing import Optional
2 |
3 | from fastapi import FastAPI
4 | from pydantic import BaseModel
5 |
6 | app = FastAPI()
7 |
8 |
9 | class Image(BaseModel):
10 | url: str
11 | name: str
12 |
13 |
14 | class Item(BaseModel):
15 | name: str
16 | description: Optional[str] = None
17 | price: float
18 | tax: Optional[float] = None
19 | tags: set[str] = []
20 | image: Optional[Image] = None
21 |
22 |
23 | @app.put("/items/{item_id}")
24 | async def update_item(item_id: int, item: Item):
25 | results = {"item_id": item_id, "item": item}
26 | return results
27 |
--------------------------------------------------------------------------------
/sugar/docs_src/body_nested_models/tutorial005_py310.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 | from pydantic import BaseModel, HttpUrl
3 |
4 | app = FastAPI()
5 |
6 |
7 | class Image(BaseModel):
8 | url: HttpUrl
9 | name: str
10 |
11 |
12 | class Item(BaseModel):
13 | name: str
14 | description: str | None = None
15 | price: float
16 | tax: float | None = None
17 | tags: set[str] = set()
18 | image: Image | None = None
19 |
20 |
21 | @app.put("/items/{item_id}")
22 | async def update_item(item_id: int, item: Item):
23 | results = {"item_id": item_id, "item": item}
24 | return results
25 |
--------------------------------------------------------------------------------
/sugar/docs_src/body_nested_models/tutorial006_py310.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 | from pydantic import BaseModel, HttpUrl
3 |
4 | app = FastAPI()
5 |
6 |
7 | class Image(BaseModel):
8 | url: HttpUrl
9 | name: str
10 |
11 |
12 | class Item(BaseModel):
13 | name: str
14 | description: str | None = None
15 | price: float
16 | tax: float | None = None
17 | tags: set[str] = set()
18 | images: list[Image] | None = None
19 |
20 |
21 | @app.put("/items/{item_id}")
22 | async def update_item(item_id: int, item: Item):
23 | results = {"item_id": item_id, "item": item}
24 | return results
25 |
--------------------------------------------------------------------------------
/sugar/docs_src/body_nested_models/tutorial008.py:
--------------------------------------------------------------------------------
1 | from typing import List
2 |
3 | from fastapi import FastAPI
4 | from pydantic import BaseModel, HttpUrl
5 |
6 | app = FastAPI()
7 |
8 |
9 | class Image(BaseModel):
10 | url: HttpUrl
11 | name: str
12 |
13 |
14 | @app.post("/images/multiple/")
15 | async def create_multiple_images(images: List[Image]):
16 | return images
17 |
--------------------------------------------------------------------------------
/sugar/docs_src/body_nested_models/tutorial008_py39.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 | from pydantic import BaseModel, HttpUrl
3 |
4 | app = FastAPI()
5 |
6 |
7 | class Image(BaseModel):
8 | url: HttpUrl
9 | name: str
10 |
11 |
12 | @app.post("/images/multiple/")
13 | async def create_multiple_images(images: list[Image]):
14 | return images
15 |
--------------------------------------------------------------------------------
/sugar/docs_src/body_nested_models/tutorial009.py:
--------------------------------------------------------------------------------
1 | from typing import Dict
2 |
3 | from fastapi import FastAPI
4 |
5 | app = FastAPI()
6 |
7 |
8 | @app.post("/index-weights/")
9 | async def create_index_weights(weights: Dict[int, float]):
10 | return weights
11 |
--------------------------------------------------------------------------------
/sugar/docs_src/body_nested_models/tutorial009_py39.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 |
3 | app = FastAPI()
4 |
5 |
6 | @app.post("/index-weights/")
7 | async def create_index_weights(weights: dict[int, float]):
8 | return weights
9 |
--------------------------------------------------------------------------------
/sugar/docs_src/conditional_openapi/tutorial001.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 | from pydantic import BaseSettings
3 |
4 |
5 | class Settings(BaseSettings):
6 | openapi_url: str = "/openapi.json"
7 |
8 |
9 | settings = Settings()
10 |
11 | app = FastAPI(openapi_url=settings.openapi_url)
12 |
13 |
14 | @app.get("/")
15 | def root():
16 | return {"message": "Hello World"}
17 |
--------------------------------------------------------------------------------
/sugar/docs_src/cookie_params/tutorial001.py:
--------------------------------------------------------------------------------
1 | from typing import Optional
2 |
3 | from fastapi import Cookie, FastAPI
4 |
5 | app = FastAPI()
6 |
7 |
8 | @app.get("/items/")
9 | async def read_items(ads_id: Optional[str] = Cookie(None)):
10 | return {"ads_id": ads_id}
11 |
--------------------------------------------------------------------------------
/sugar/docs_src/cookie_params/tutorial001_py310.py:
--------------------------------------------------------------------------------
1 | from fastapi import Cookie, FastAPI
2 |
3 | app = FastAPI()
4 |
5 |
6 | @app.get("/items/")
7 | async def read_items(ads_id: str | None = Cookie(None)):
8 | return {"ads_id": ads_id}
9 |
--------------------------------------------------------------------------------
/sugar/docs_src/cors/tutorial001.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 | from fastapi.middleware.cors import CORSMiddleware
3 |
4 | app = FastAPI()
5 |
6 | origins = [
7 | "http://localhost.tiangolo.com",
8 | "https://localhost.tiangolo.com",
9 | "http://localhost",
10 | "http://localhost:8080",
11 | ]
12 |
13 | app.add_middleware(
14 | CORSMiddleware,
15 | allow_origins=origins,
16 | allow_credentials=True,
17 | allow_methods=["*"],
18 | allow_headers=["*"],
19 | )
20 |
21 |
22 | @app.get("/")
23 | async def main():
24 | return {"message": "Hello World"}
25 |
--------------------------------------------------------------------------------
/sugar/docs_src/custom_response/tutorial001.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 | from fastapi.responses import UJSONResponse
3 |
4 | app = FastAPI()
5 |
6 |
7 | @app.get("/items/", response_class=UJSONResponse)
8 | async def read_items():
9 | return [{"item_id": "Foo"}]
10 |
--------------------------------------------------------------------------------
/sugar/docs_src/custom_response/tutorial001b.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 | from fastapi.responses import ORJSONResponse
3 |
4 | app = FastAPI()
5 |
6 |
7 | @app.get("/items/", response_class=ORJSONResponse)
8 | async def read_items():
9 | return [{"item_id": "Foo"}]
10 |
--------------------------------------------------------------------------------
/sugar/docs_src/custom_response/tutorial002.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 | from fastapi.responses import HTMLResponse
3 |
4 | app = FastAPI()
5 |
6 |
7 | @app.get("/items/", response_class=HTMLResponse)
8 | async def read_items():
9 | return """
10 |
11 |
12 | Some HTML in here
13 |
14 |
15 | Look ma! HTML!
16 |
17 |
18 | """
19 |
--------------------------------------------------------------------------------
/sugar/docs_src/custom_response/tutorial003.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 | from fastapi.responses import HTMLResponse
3 |
4 | app = FastAPI()
5 |
6 |
7 | @app.get("/items/")
8 | async def read_items():
9 | html_content = """
10 |
11 |
12 | Some HTML in here
13 |
14 |
15 | Look ma! HTML!
16 |
17 |
18 | """
19 | return HTMLResponse(content=html_content, status_code=200)
20 |
--------------------------------------------------------------------------------
/sugar/docs_src/custom_response/tutorial004.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 | from fastapi.responses import HTMLResponse
3 |
4 | app = FastAPI()
5 |
6 |
7 | def generate_html_response():
8 | html_content = """
9 |
10 |
11 | Some HTML in here
12 |
13 |
14 | Look ma! HTML!
15 |
16 |
17 | """
18 | return HTMLResponse(content=html_content, status_code=200)
19 |
20 |
21 | @app.get("/items/", response_class=HTMLResponse)
22 | async def read_items():
23 | return generate_html_response()
24 |
--------------------------------------------------------------------------------
/sugar/docs_src/custom_response/tutorial005.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 | from fastapi.responses import PlainTextResponse
3 |
4 | app = FastAPI()
5 |
6 |
7 | @app.get("/", response_class=PlainTextResponse)
8 | async def main():
9 | return "Hello World"
10 |
--------------------------------------------------------------------------------
/sugar/docs_src/custom_response/tutorial006.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 | from fastapi.responses import RedirectResponse
3 |
4 | app = FastAPI()
5 |
6 |
7 | @app.get("/typer")
8 | async def redirect_typer():
9 | return RedirectResponse("https://typer.tiangolo.com")
10 |
--------------------------------------------------------------------------------
/sugar/docs_src/custom_response/tutorial006b.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 | from fastapi.responses import RedirectResponse
3 |
4 | app = FastAPI()
5 |
6 |
7 | @app.get("/fastapi", response_class=RedirectResponse)
8 | async def redirect_fastapi():
9 | return "https://fastapi.tiangolo.com"
10 |
--------------------------------------------------------------------------------
/sugar/docs_src/custom_response/tutorial006c.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 | from fastapi.responses import RedirectResponse
3 |
4 | app = FastAPI()
5 |
6 |
7 | @app.get("/pydantic", response_class=RedirectResponse, status_code=302)
8 | async def redirect_pydantic():
9 | return "https://pydantic-docs.helpmanual.io/"
10 |
--------------------------------------------------------------------------------
/sugar/docs_src/custom_response/tutorial007.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 | from fastapi.responses import StreamingResponse
3 |
4 | app = FastAPI()
5 |
6 |
7 | async def fake_video_streamer():
8 | for i in range(10):
9 | yield b"some fake video bytes"
10 |
11 |
12 | @app.get("/")
13 | async def main():
14 | return StreamingResponse(fake_video_streamer())
15 |
--------------------------------------------------------------------------------
/sugar/docs_src/custom_response/tutorial008.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 | from fastapi.responses import StreamingResponse
3 |
4 | some_file_path = "large-video-file.mp4"
5 | app = FastAPI()
6 |
7 |
8 | @app.get("/")
9 | def main():
10 | def iterfile(): # (1)
11 | with open(some_file_path, mode="rb") as file_like: # (2)
12 | yield from file_like # (3)
13 |
14 | return StreamingResponse(iterfile(), media_type="video/mp4")
15 |
--------------------------------------------------------------------------------
/sugar/docs_src/custom_response/tutorial009.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 | from fastapi.responses import FileResponse
3 |
4 | some_file_path = "large-video-file.mp4"
5 | app = FastAPI()
6 |
7 |
8 | @app.get("/")
9 | async def main():
10 | return FileResponse(some_file_path)
11 |
--------------------------------------------------------------------------------
/sugar/docs_src/custom_response/tutorial009b.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 | from fastapi.responses import FileResponse
3 |
4 | some_file_path = "large-video-file.mp4"
5 | app = FastAPI()
6 |
7 |
8 | @app.get("/", response_class=FileResponse)
9 | async def main():
10 | return some_file_path
11 |
--------------------------------------------------------------------------------
/sugar/docs_src/custom_response/tutorial010.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 | from fastapi.responses import ORJSONResponse
3 |
4 | app = FastAPI(default_response_class=ORJSONResponse)
5 |
6 |
7 | @app.get("/items/")
8 | async def read_items():
9 | return [{"item_id": "Foo"}]
10 |
--------------------------------------------------------------------------------
/sugar/docs_src/dataclasses/tutorial001.py:
--------------------------------------------------------------------------------
1 | from dataclasses import dataclass
2 | from typing import Optional
3 |
4 | from fastapi import FastAPI
5 |
6 |
7 | @dataclass
8 | class Item:
9 | name: str
10 | price: float
11 | description: Optional[str] = None
12 | tax: Optional[float] = None
13 |
14 |
15 | app = FastAPI()
16 |
17 |
18 | @app.post("/items/")
19 | async def create_item(item: Item):
20 | return item
21 |
--------------------------------------------------------------------------------
/sugar/docs_src/debugging/tutorial001.py:
--------------------------------------------------------------------------------
1 | import uvicorn
2 | from fastapi import FastAPI
3 |
4 | app = FastAPI()
5 |
6 |
7 | @app.get("/")
8 | def root():
9 | a = "a"
10 | b = "b" + a
11 | return {"hello world": b}
12 |
13 |
14 | if __name__ == "__main__":
15 | uvicorn.run(app, host="0.0.0.0", port=8000)
16 |
--------------------------------------------------------------------------------
/sugar/docs_src/dependencies/tutorial001.py:
--------------------------------------------------------------------------------
1 | from typing import Optional
2 |
3 | from fastapi import Depends, FastAPI
4 |
5 | app = FastAPI()
6 |
7 |
8 | async def common_parameters(q: Optional[str] = None, skip: int = 0, limit: int = 100):
9 | return {"q": q, "skip": skip, "limit": limit}
10 |
11 |
12 | @app.get("/items/")
13 | async def read_items(commons: dict = Depends(common_parameters)):
14 | return commons
15 |
16 |
17 | @app.get("/users/")
18 | async def read_users(commons: dict = Depends(common_parameters)):
19 | return commons
20 |
--------------------------------------------------------------------------------
/sugar/docs_src/dependencies/tutorial001_py310.py:
--------------------------------------------------------------------------------
1 | from fastapi import Depends, FastAPI
2 |
3 | app = FastAPI()
4 |
5 |
6 | async def common_parameters(q: str | None = None, skip: int = 0, limit: int = 100):
7 | return {"q": q, "skip": skip, "limit": limit}
8 |
9 |
10 | @app.get("/items/")
11 | async def read_items(commons: dict = Depends(common_parameters)):
12 | return commons
13 |
14 |
15 | @app.get("/users/")
16 | async def read_users(commons: dict = Depends(common_parameters)):
17 | return commons
18 |
--------------------------------------------------------------------------------
/sugar/docs_src/dependencies/tutorial005.py:
--------------------------------------------------------------------------------
1 | from typing import Optional
2 |
3 | from fastapi import Cookie, Depends, FastAPI
4 |
5 | app = FastAPI()
6 |
7 |
8 | def query_extractor(q: Optional[str] = None):
9 | return q
10 |
11 |
12 | def query_or_cookie_extractor(
13 | q: str = Depends(query_extractor), last_query: Optional[str] = Cookie(None)
14 | ):
15 | if not q:
16 | return last_query
17 | return q
18 |
19 |
20 | @app.get("/items/")
21 | async def read_query(query_or_default: str = Depends(query_or_cookie_extractor)):
22 | return {"q_or_cookie": query_or_default}
23 |
--------------------------------------------------------------------------------
/sugar/docs_src/dependencies/tutorial005_py310.py:
--------------------------------------------------------------------------------
1 | from fastapi import Cookie, Depends, FastAPI
2 |
3 | app = FastAPI()
4 |
5 |
6 | def query_extractor(q: str | None = None):
7 | return q
8 |
9 |
10 | def query_or_cookie_extractor(
11 | q: str = Depends(query_extractor), last_query: str | None = Cookie(None)
12 | ):
13 | if not q:
14 | return last_query
15 | return q
16 |
17 |
18 | @app.get("/items/")
19 | async def read_query(query_or_default: str = Depends(query_or_cookie_extractor)):
20 | return {"q_or_cookie": query_or_default}
21 |
--------------------------------------------------------------------------------
/sugar/docs_src/dependencies/tutorial007.py:
--------------------------------------------------------------------------------
1 | async def get_db():
2 | db = DBSession()
3 | try:
4 | yield db
5 | finally:
6 | db.close()
7 |
--------------------------------------------------------------------------------
/sugar/docs_src/dependencies/tutorial008.py:
--------------------------------------------------------------------------------
1 | from fastapi import Depends
2 |
3 |
4 | async def dependency_a():
5 | dep_a = generate_dep_a()
6 | try:
7 | yield dep_a
8 | finally:
9 | dep_a.close()
10 |
11 |
12 | async def dependency_b(dep_a=Depends(dependency_a)):
13 | dep_b = generate_dep_b()
14 | try:
15 | yield dep_b
16 | finally:
17 | dep_b.close(dep_a)
18 |
19 |
20 | async def dependency_c(dep_b=Depends(dependency_b)):
21 | dep_c = generate_dep_c()
22 | try:
23 | yield dep_c
24 | finally:
25 | dep_c.close(dep_b)
26 |
--------------------------------------------------------------------------------
/sugar/docs_src/dependencies/tutorial009.py:
--------------------------------------------------------------------------------
1 | from fastapi import Depends
2 |
3 |
4 | async def dependency_a():
5 | dep_a = generate_dep_a()
6 | try:
7 | yield dep_a
8 | finally:
9 | dep_a.close()
10 |
11 |
12 | async def dependency_b(dep_a=Depends(dependency_a)):
13 | dep_b = generate_dep_b()
14 | try:
15 | yield dep_b
16 | finally:
17 | dep_b.close(dep_a)
18 |
19 |
20 | async def dependency_c(dep_b=Depends(dependency_b)):
21 | dep_c = generate_dep_c()
22 | try:
23 | yield dep_c
24 | finally:
25 | dep_c.close(dep_b)
26 |
--------------------------------------------------------------------------------
/sugar/docs_src/dependencies/tutorial010.py:
--------------------------------------------------------------------------------
1 | class MySuperContextManager:
2 | def __init__(self):
3 | self.db = DBSession()
4 |
5 | def __enter__(self):
6 | return self.db
7 |
8 | def __exit__(self, exc_type, exc_value, traceback):
9 | self.db.close()
10 |
11 |
12 | async def get_db():
13 | with MySuperContextManager() as db:
14 | yield db
15 |
--------------------------------------------------------------------------------
/sugar/docs_src/dependencies/tutorial011.py:
--------------------------------------------------------------------------------
1 | from fastapi import Depends, FastAPI
2 |
3 | app = FastAPI()
4 |
5 |
6 | class FixedContentQueryChecker:
7 | def __init__(self, fixed_content: str):
8 | self.fixed_content = fixed_content
9 |
10 | def __call__(self, q: str = ""):
11 | if q:
12 | return self.fixed_content in q
13 | return False
14 |
15 |
16 | checker = FixedContentQueryChecker("bar")
17 |
18 |
19 | @app.get("/query-checker/")
20 | async def read_query_check(fixed_content_included: bool = Depends(checker)):
21 | return {"fixed_content_in_query": fixed_content_included}
22 |
--------------------------------------------------------------------------------
/sugar/docs_src/encoder/tutorial001.py:
--------------------------------------------------------------------------------
1 | from datetime import datetime
2 | from typing import Optional
3 |
4 | from fastapi import FastAPI
5 | from fastapi.encoders import jsonable_encoder
6 | from pydantic import BaseModel
7 |
8 | fake_db = {}
9 |
10 |
11 | class Item(BaseModel):
12 | title: str
13 | timestamp: datetime
14 | description: Optional[str] = None
15 |
16 |
17 | app = FastAPI()
18 |
19 |
20 | @app.put("/items/{id}")
21 | def update_item(id: str, item: Item):
22 | json_compatible_item_data = jsonable_encoder(item)
23 | fake_db[id] = json_compatible_item_data
24 |
--------------------------------------------------------------------------------
/sugar/docs_src/encoder/tutorial001_py310.py:
--------------------------------------------------------------------------------
1 | from datetime import datetime
2 |
3 | from fastapi import FastAPI
4 | from fastapi.encoders import jsonable_encoder
5 | from pydantic import BaseModel
6 |
7 | fake_db = {}
8 |
9 |
10 | class Item(BaseModel):
11 | title: str
12 | timestamp: datetime
13 | description: str | None = None
14 |
15 |
16 | app = FastAPI()
17 |
18 |
19 | @app.put("/items/{id}")
20 | def update_item(id: str, item: Item):
21 | json_compatible_item_data = jsonable_encoder(item)
22 | fake_db[id] = json_compatible_item_data
23 |
--------------------------------------------------------------------------------
/sugar/docs_src/events/tutorial001.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 |
3 | app = FastAPI()
4 |
5 | items = {}
6 |
7 |
8 | @app.on_event("startup")
9 | async def startup_event():
10 | items["foo"] = {"name": "Fighters"}
11 | items["bar"] = {"name": "Tenders"}
12 |
13 |
14 | @app.get("/items/{item_id}")
15 | async def read_items(item_id: str):
16 | return items[item_id]
17 |
--------------------------------------------------------------------------------
/sugar/docs_src/events/tutorial002.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 |
3 | app = FastAPI()
4 |
5 |
6 | @app.on_event("shutdown")
7 | def shutdown_event():
8 | with open("log.txt", mode="a") as log:
9 | log.write("Application shutdown")
10 |
11 |
12 | @app.get("/items/")
13 | async def read_items():
14 | return [{"name": "Foo"}]
15 |
--------------------------------------------------------------------------------
/sugar/docs_src/extra_models/tutorial004.py:
--------------------------------------------------------------------------------
1 | from typing import List
2 |
3 | from fastapi import FastAPI
4 | from pydantic import BaseModel
5 |
6 | app = FastAPI()
7 |
8 |
9 | class Item(BaseModel):
10 | name: str
11 | description: str
12 |
13 |
14 | items = [
15 | {"name": "Foo", "description": "There comes my hero"},
16 | {"name": "Red", "description": "It's my aeroplane"},
17 | ]
18 |
19 |
20 | @app.get("/items/", response_model=List[Item])
21 | async def read_items():
22 | return items
23 |
--------------------------------------------------------------------------------
/sugar/docs_src/extra_models/tutorial004_py39.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 | from pydantic import BaseModel
3 |
4 | app = FastAPI()
5 |
6 |
7 | class Item(BaseModel):
8 | name: str
9 | description: str
10 |
11 |
12 | items = [
13 | {"name": "Foo", "description": "There comes my hero"},
14 | {"name": "Red", "description": "It's my aeroplane"},
15 | ]
16 |
17 |
18 | @app.get("/items/", response_model=list[Item])
19 | async def read_items():
20 | return items
21 |
--------------------------------------------------------------------------------
/sugar/docs_src/extra_models/tutorial005.py:
--------------------------------------------------------------------------------
1 | from typing import Dict
2 |
3 | from fastapi import FastAPI
4 |
5 | app = FastAPI()
6 |
7 |
8 | @app.get("/keyword-weights/", response_model=Dict[str, float])
9 | async def read_keyword_weights():
10 | return {"foo": 2.3, "bar": 3.4}
11 |
--------------------------------------------------------------------------------
/sugar/docs_src/extra_models/tutorial005_py39.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 |
3 | app = FastAPI()
4 |
5 |
6 | @app.get("/keyword-weights/", response_model=dict[str, float])
7 | async def read_keyword_weights():
8 | return {"foo": 2.3, "bar": 3.4}
9 |
--------------------------------------------------------------------------------
/sugar/docs_src/first_steps/tutorial001.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 |
3 | app = FastAPI()
4 |
5 |
6 | @app.get("/")
7 | async def root():
8 | return {"message": "Hello World"}
9 |
--------------------------------------------------------------------------------
/sugar/docs_src/first_steps/tutorial002.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 |
3 | my_awesome_api = FastAPI()
4 |
5 |
6 | @my_awesome_api.get("/")
7 | async def root():
8 | return {"message": "Hello World"}
9 |
--------------------------------------------------------------------------------
/sugar/docs_src/first_steps/tutorial003.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 |
3 | app = FastAPI()
4 |
5 |
6 | @app.get("/")
7 | def root():
8 | return {"message": "Hello World"}
9 |
--------------------------------------------------------------------------------
/sugar/docs_src/graphql/tutorial001.py:
--------------------------------------------------------------------------------
1 | import strawberry
2 | from fastapi import FastAPI
3 | from strawberry.asgi import GraphQL
4 |
5 |
6 | @strawberry.type
7 | class User:
8 | name: str
9 | age: int
10 |
11 |
12 | @strawberry.type
13 | class Query:
14 | @strawberry.field
15 | def user(self) -> User:
16 | return User(name="Patrick", age=100)
17 |
18 |
19 | schema = strawberry.Schema(query=Query)
20 |
21 |
22 | graphql_app = GraphQL(schema)
23 |
24 | app = FastAPI()
25 | app.add_route("/graphql", graphql_app)
26 | app.add_websocket_route("/graphql", graphql_app)
27 |
--------------------------------------------------------------------------------
/sugar/docs_src/handling_errors/tutorial001.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI, HTTPException
2 |
3 | app = FastAPI()
4 |
5 | items = {"foo": "The Foo Wrestlers"}
6 |
7 |
8 | @app.get("/items/{item_id}")
9 | async def read_item(item_id: str):
10 | if item_id not in items:
11 | raise HTTPException(status_code=404, detail="Item not found")
12 | return {"item": items[item_id]}
13 |
--------------------------------------------------------------------------------
/sugar/docs_src/handling_errors/tutorial002.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI, HTTPException
2 |
3 | app = FastAPI()
4 |
5 | items = {"foo": "The Foo Wrestlers"}
6 |
7 |
8 | @app.get("/items-header/{item_id}")
9 | async def read_item_header(item_id: str):
10 | if item_id not in items:
11 | raise HTTPException(
12 | status_code=404,
13 | detail="Item not found",
14 | headers={"X-Error": "There goes my error"},
15 | )
16 | return {"item": items[item_id]}
17 |
--------------------------------------------------------------------------------
/sugar/docs_src/header_params/tutorial001.py:
--------------------------------------------------------------------------------
1 | from typing import Optional
2 |
3 | from fastapi import FastAPI, Header
4 |
5 | app = FastAPI()
6 |
7 |
8 | @app.get("/items/")
9 | async def read_items(user_agent: Optional[str] = Header(None)):
10 | return {"User-Agent": user_agent}
11 |
--------------------------------------------------------------------------------
/sugar/docs_src/header_params/tutorial001_py310.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI, Header
2 |
3 | app = FastAPI()
4 |
5 |
6 | @app.get("/items/")
7 | async def read_items(user_agent: str | None = Header(None)):
8 | return {"User-Agent": user_agent}
9 |
--------------------------------------------------------------------------------
/sugar/docs_src/header_params/tutorial002.py:
--------------------------------------------------------------------------------
1 | from typing import Optional
2 |
3 | from fastapi import FastAPI, Header
4 |
5 | app = FastAPI()
6 |
7 |
8 | @app.get("/items/")
9 | async def read_items(
10 | strange_header: Optional[str] = Header(None, convert_underscores=False)
11 | ):
12 | return {"strange_header": strange_header}
13 |
--------------------------------------------------------------------------------
/sugar/docs_src/header_params/tutorial002_py310.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI, Header
2 |
3 | app = FastAPI()
4 |
5 |
6 | @app.get("/items/")
7 | async def read_items(
8 | strange_header: str | None = Header(None, convert_underscores=False)
9 | ):
10 | return {"strange_header": strange_header}
11 |
--------------------------------------------------------------------------------
/sugar/docs_src/header_params/tutorial003.py:
--------------------------------------------------------------------------------
1 | from typing import List, Optional
2 |
3 | from fastapi import FastAPI, Header
4 |
5 | app = FastAPI()
6 |
7 |
8 | @app.get("/items/")
9 | async def read_items(x_token: Optional[List[str]] = Header(None)):
10 | return {"X-Token values": x_token}
11 |
--------------------------------------------------------------------------------
/sugar/docs_src/header_params/tutorial003_py310.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI, Header
2 |
3 | app = FastAPI()
4 |
5 |
6 | @app.get("/items/")
7 | async def read_items(x_token: list[str] | None = Header(None)):
8 | return {"X-Token values": x_token}
9 |
--------------------------------------------------------------------------------
/sugar/docs_src/header_params/tutorial003_py39.py:
--------------------------------------------------------------------------------
1 | from typing import Optional
2 |
3 | from fastapi import FastAPI, Header
4 |
5 | app = FastAPI()
6 |
7 |
8 | @app.get("/items/")
9 | async def read_items(x_token: Optional[list[str]] = Header(None)):
10 | return {"X-Token values": x_token}
11 |
--------------------------------------------------------------------------------
/sugar/docs_src/metadata/tutorial002.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 |
3 | app = FastAPI(openapi_url="/api/v1/openapi.json")
4 |
5 |
6 | @app.get("/items/")
7 | async def read_items():
8 | return [{"name": "Foo"}]
9 |
--------------------------------------------------------------------------------
/sugar/docs_src/metadata/tutorial003.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 |
3 | app = FastAPI(docs_url="/documentation", redoc_url=None)
4 |
5 |
6 | @app.get("/items/")
7 | async def read_items():
8 | return [{"name": "Foo"}]
9 |
--------------------------------------------------------------------------------
/sugar/docs_src/middleware/tutorial001.py:
--------------------------------------------------------------------------------
1 | import time
2 |
3 | from fastapi import FastAPI, Request
4 |
5 | app = FastAPI()
6 |
7 |
8 | @app.middleware("http")
9 | async def add_process_time_header(request: Request, call_next):
10 | start_time = time.time()
11 | response = await call_next(request)
12 | process_time = time.time() - start_time
13 | response.headers["X-Process-Time"] = str(process_time)
14 | return response
15 |
--------------------------------------------------------------------------------
/sugar/docs_src/path_operation_advanced_configuration/tutorial001.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 |
3 | app = FastAPI()
4 |
5 |
6 | @app.get("/items/", operation_id="some_specific_id_you_define")
7 | async def read_items():
8 | return [{"item_id": "Foo"}]
9 |
--------------------------------------------------------------------------------
/sugar/docs_src/path_operation_advanced_configuration/tutorial003.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 |
3 | app = FastAPI()
4 |
5 |
6 | @app.get("/items/", include_in_schema=False)
7 | async def read_items():
8 | return [{"item_id": "Foo"}]
9 |
--------------------------------------------------------------------------------
/sugar/docs_src/path_operation_advanced_configuration/tutorial005.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 |
3 | app = FastAPI()
4 |
5 |
6 | @app.get("/items/", openapi_extra={"x-aperture-labs-portal": "blue"})
7 | async def read_items():
8 | return [{"item_id": "portal-gun"}]
9 |
--------------------------------------------------------------------------------
/sugar/docs_src/path_operation_configuration/tutorial001.py:
--------------------------------------------------------------------------------
1 | from typing import Optional, Set
2 |
3 | from fastapi import FastAPI, status
4 | from pydantic import BaseModel
5 |
6 | app = FastAPI()
7 |
8 |
9 | class Item(BaseModel):
10 | name: str
11 | description: Optional[str] = None
12 | price: float
13 | tax: Optional[float] = None
14 | tags: Set[str] = set()
15 |
16 |
17 | @app.post("/items/", response_model=Item, status_code=status.HTTP_201_CREATED)
18 | async def create_item(item: Item):
19 | return item
20 |
--------------------------------------------------------------------------------
/sugar/docs_src/path_operation_configuration/tutorial001_py310.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI, status
2 | from pydantic import BaseModel
3 |
4 | app = FastAPI()
5 |
6 |
7 | class Item(BaseModel):
8 | name: str
9 | description: str | None = None
10 | price: float
11 | tax: float | None = None
12 | tags: set[str] = set()
13 |
14 |
15 | @app.post("/items/", response_model=Item, status_code=status.HTTP_201_CREATED)
16 | async def create_item(item: Item):
17 | return item
18 |
--------------------------------------------------------------------------------
/sugar/docs_src/path_operation_configuration/tutorial001_py39.py:
--------------------------------------------------------------------------------
1 | from typing import Optional
2 |
3 | from fastapi import FastAPI, status
4 | from pydantic import BaseModel
5 |
6 | app = FastAPI()
7 |
8 |
9 | class Item(BaseModel):
10 | name: str
11 | description: Optional[str] = None
12 | price: float
13 | tax: Optional[float] = None
14 | tags: set[str] = set()
15 |
16 |
17 | @app.post("/items/", response_model=Item, status_code=status.HTTP_201_CREATED)
18 | async def create_item(item: Item):
19 | return item
20 |
--------------------------------------------------------------------------------
/sugar/docs_src/path_operation_configuration/tutorial003_py310.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 | from pydantic import BaseModel
3 |
4 | app = FastAPI()
5 |
6 |
7 | class Item(BaseModel):
8 | name: str
9 | description: str | None = None
10 | price: float
11 | tax: float | None = None
12 | tags: set[str] = set()
13 |
14 |
15 | @app.post(
16 | "/items/",
17 | response_model=Item,
18 | summary="Create an item",
19 | description="Create an item with all the information, name, description, price, tax and a set of unique tags",
20 | )
21 | async def create_item(item: Item):
22 | return item
23 |
--------------------------------------------------------------------------------
/sugar/docs_src/path_operation_configuration/tutorial006.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 |
3 | app = FastAPI()
4 |
5 |
6 | @app.get("/items/", tags=["items"])
7 | async def read_items():
8 | return [{"name": "Foo", "price": 42}]
9 |
10 |
11 | @app.get("/users/", tags=["users"])
12 | async def read_users():
13 | return [{"username": "johndoe"}]
14 |
15 |
16 | @app.get("/elements/", tags=["items"], deprecated=True)
17 | async def read_elements():
18 | return [{"item_id": "Foo"}]
19 |
--------------------------------------------------------------------------------
/sugar/docs_src/path_params/tutorial001.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 |
3 | app = FastAPI()
4 |
5 |
6 | @app.get("/items/{item_id}")
7 | async def read_item(item_id):
8 | return {"item_id": item_id}
9 |
--------------------------------------------------------------------------------
/sugar/docs_src/path_params/tutorial002.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 |
3 | app = FastAPI()
4 |
5 |
6 | @app.get("/items/{item_id}")
7 | async def read_item(item_id: int):
8 | return {"item_id": item_id}
9 |
--------------------------------------------------------------------------------
/sugar/docs_src/path_params/tutorial003.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 |
3 | app = FastAPI()
4 |
5 |
6 | @app.get("/users/me")
7 | async def read_user_me():
8 | return {"user_id": "the current user"}
9 |
10 |
11 | @app.get("/users/{user_id}")
12 | async def read_user(user_id: str):
13 | return {"user_id": user_id}
14 |
--------------------------------------------------------------------------------
/sugar/docs_src/path_params/tutorial004.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 |
3 | app = FastAPI()
4 |
5 |
6 | @app.get("/files/{file_path:path}")
7 | async def read_file(file_path: str):
8 | return {"file_path": file_path}
9 |
--------------------------------------------------------------------------------
/sugar/docs_src/path_params_numeric_validations/tutorial001.py:
--------------------------------------------------------------------------------
1 | from typing import Optional
2 |
3 | from fastapi import FastAPI, Path, Query
4 |
5 | app = FastAPI()
6 |
7 |
8 | @app.get("/items/{item_id}")
9 | async def read_items(
10 | item_id: int = Path(..., title="The ID of the item to get"),
11 | q: Optional[str] = Query(None, alias="item-query"),
12 | ):
13 | results = {"item_id": item_id}
14 | if q:
15 | results.update({"q": q})
16 | return results
17 |
--------------------------------------------------------------------------------
/sugar/docs_src/path_params_numeric_validations/tutorial001_py310.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI, Path, Query
2 |
3 | app = FastAPI()
4 |
5 |
6 | @app.get("/items/{item_id}")
7 | async def read_items(
8 | item_id: int = Path(..., title="The ID of the item to get"),
9 | q: str | None = Query(None, alias="item-query"),
10 | ):
11 | results = {"item_id": item_id}
12 | if q:
13 | results.update({"q": q})
14 | return results
15 |
--------------------------------------------------------------------------------
/sugar/docs_src/path_params_numeric_validations/tutorial002.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI, Path
2 |
3 | app = FastAPI()
4 |
5 |
6 | @app.get("/items/{item_id}")
7 | async def read_items(
8 | q: str, item_id: int = Path(..., title="The ID of the item to get")
9 | ):
10 | results = {"item_id": item_id}
11 | if q:
12 | results.update({"q": q})
13 | return results
14 |
--------------------------------------------------------------------------------
/sugar/docs_src/path_params_numeric_validations/tutorial003.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI, Path
2 |
3 | app = FastAPI()
4 |
5 |
6 | @app.get("/items/{item_id}")
7 | async def read_items(
8 | *, item_id: int = Path(..., title="The ID of the item to get"), q: str
9 | ):
10 | results = {"item_id": item_id}
11 | if q:
12 | results.update({"q": q})
13 | return results
14 |
--------------------------------------------------------------------------------
/sugar/docs_src/path_params_numeric_validations/tutorial004.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI, Path
2 |
3 | app = FastAPI()
4 |
5 |
6 | @app.get("/items/{item_id}")
7 | async def read_items(
8 | *, item_id: int = Path(..., title="The ID of the item to get", ge=1), q: str
9 | ):
10 | results = {"item_id": item_id}
11 | if q:
12 | results.update({"q": q})
13 | return results
14 |
--------------------------------------------------------------------------------
/sugar/docs_src/path_params_numeric_validations/tutorial005.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI, Path
2 |
3 | app = FastAPI()
4 |
5 |
6 | @app.get("/items/{item_id}")
7 | async def read_items(
8 | *,
9 | item_id: int = Path(..., title="The ID of the item to get", gt=0, le=1000),
10 | q: str,
11 | ):
12 | results = {"item_id": item_id}
13 | if q:
14 | results.update({"q": q})
15 | return results
16 |
--------------------------------------------------------------------------------
/sugar/docs_src/path_params_numeric_validations/tutorial006.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI, Path, Query
2 |
3 | app = FastAPI()
4 |
5 |
6 | @app.get("/items/{item_id}")
7 | async def read_items(
8 | *,
9 | item_id: int = Path(..., title="The ID of the item to get", ge=0, le=1000),
10 | q: str,
11 | size: float = Query(..., gt=0, lt=10.5)
12 | ):
13 | results = {"item_id": item_id}
14 | if q:
15 | results.update({"q": q})
16 | return results
17 |
--------------------------------------------------------------------------------
/sugar/docs_src/python_types/tutorial001.py:
--------------------------------------------------------------------------------
1 | def get_full_name(first_name, last_name):
2 | full_name = first_name.title() + " " + last_name.title()
3 | return full_name
4 |
5 |
6 | print(get_full_name("john", "doe"))
7 |
--------------------------------------------------------------------------------
/sugar/docs_src/python_types/tutorial002.py:
--------------------------------------------------------------------------------
1 | def get_full_name(first_name: str, last_name: str):
2 | full_name = first_name.title() + " " + last_name.title()
3 | return full_name
4 |
5 |
6 | print(get_full_name("john", "doe"))
7 |
--------------------------------------------------------------------------------
/sugar/docs_src/python_types/tutorial003.py:
--------------------------------------------------------------------------------
1 | def get_name_with_age(name: str, age: int):
2 | name_with_age = name + " is this old: " + age
3 | return name_with_age
4 |
--------------------------------------------------------------------------------
/sugar/docs_src/python_types/tutorial004.py:
--------------------------------------------------------------------------------
1 | def get_name_with_age(name: str, age: int):
2 | name_with_age = name + " is this old: " + str(age)
3 | return name_with_age
4 |
--------------------------------------------------------------------------------
/sugar/docs_src/python_types/tutorial005.py:
--------------------------------------------------------------------------------
1 | def get_items(item_a: str, item_b: int, item_c: float, item_d: bool, item_e: bytes):
2 | return item_a, item_b, item_c, item_d, item_d, item_e
3 |
--------------------------------------------------------------------------------
/sugar/docs_src/python_types/tutorial006.py:
--------------------------------------------------------------------------------
1 | from typing import List
2 |
3 |
4 | def process_items(items: List[str]):
5 | for item in items:
6 | print(item)
7 |
--------------------------------------------------------------------------------
/sugar/docs_src/python_types/tutorial006_py39.py:
--------------------------------------------------------------------------------
1 | def process_items(items: list[str]):
2 | for item in items:
3 | print(item)
4 |
--------------------------------------------------------------------------------
/sugar/docs_src/python_types/tutorial007.py:
--------------------------------------------------------------------------------
1 | from typing import Set, Tuple
2 |
3 |
4 | def process_items(items_t: Tuple[int, int, str], items_s: Set[bytes]):
5 | return items_t, items_s
6 |
--------------------------------------------------------------------------------
/sugar/docs_src/python_types/tutorial007_py39.py:
--------------------------------------------------------------------------------
1 | def process_items(items_t: tuple[int, int, str], items_s: set[bytes]):
2 | return items_t, items_s
3 |
--------------------------------------------------------------------------------
/sugar/docs_src/python_types/tutorial008.py:
--------------------------------------------------------------------------------
1 | def process_items(prices: dict[str, float]):
2 | for item_name, item_price in prices.items():
3 | print(item_name)
4 | print(item_price)
5 |
--------------------------------------------------------------------------------
/sugar/docs_src/python_types/tutorial008b.py:
--------------------------------------------------------------------------------
1 | from typing import Union
2 |
3 |
4 | def process_item(item: Union[int, str]):
5 | print(item)
6 |
--------------------------------------------------------------------------------
/sugar/docs_src/python_types/tutorial008b_py310.py:
--------------------------------------------------------------------------------
1 | def process_item(item: int | str):
2 | print(item)
3 |
--------------------------------------------------------------------------------
/sugar/docs_src/python_types/tutorial009.py:
--------------------------------------------------------------------------------
1 | from typing import Optional
2 |
3 |
4 | def say_hi(name: Optional[str] = None):
5 | if name is not None:
6 | print(f"Hey {name}!")
7 | else:
8 | print("Hello World")
9 |
--------------------------------------------------------------------------------
/sugar/docs_src/python_types/tutorial009_py310.py:
--------------------------------------------------------------------------------
1 | def say_hi(name: str | None = None):
2 | if name is not None:
3 | print(f"Hey {name}!")
4 | else:
5 | print("Hello World")
6 |
--------------------------------------------------------------------------------
/sugar/docs_src/python_types/tutorial009b.py:
--------------------------------------------------------------------------------
1 | from typing import Union
2 |
3 |
4 | def say_hi(name: Union[str, None] = None):
5 | if name is not None:
6 | print(f"Hey {name}!")
7 | else:
8 | print("Hello World")
9 |
--------------------------------------------------------------------------------
/sugar/docs_src/python_types/tutorial010.py:
--------------------------------------------------------------------------------
1 | class Person:
2 | def __init__(self, name: str):
3 | self.name = name
4 |
5 |
6 | def get_person_name(one_person: Person):
7 | return one_person.name
8 |
--------------------------------------------------------------------------------
/sugar/docs_src/python_types/tutorial011.py:
--------------------------------------------------------------------------------
1 | from datetime import datetime
2 | from typing import List, Optional
3 |
4 | from pydantic import BaseModel
5 |
6 |
7 | class User(BaseModel):
8 | id: int
9 | name = "John Doe"
10 | signup_ts: Optional[datetime] = None
11 | friends: List[int] = []
12 |
13 |
14 | external_data = {
15 | "id": "123",
16 | "signup_ts": "2017-06-01 12:22",
17 | "friends": [1, "2", b"3"],
18 | }
19 | user = User(**external_data)
20 | print(user)
21 | # > User id=123 name='John Doe' signup_ts=datetime.datetime(2017, 6, 1, 12, 22) friends=[1, 2, 3]
22 | print(user.id)
23 | # > 123
24 |
--------------------------------------------------------------------------------
/sugar/docs_src/python_types/tutorial011_py310.py:
--------------------------------------------------------------------------------
1 | from datetime import datetime
2 |
3 | from pydantic import BaseModel
4 |
5 |
6 | class User(BaseModel):
7 | id: int
8 | name = "John Doe"
9 | signup_ts: datetime | None = None
10 | friends: list[int] = []
11 |
12 |
13 | external_data = {
14 | "id": "123",
15 | "signup_ts": "2017-06-01 12:22",
16 | "friends": [1, "2", b"3"],
17 | }
18 | user = User(**external_data)
19 | print(user)
20 | # > User id=123 name='John Doe' signup_ts=datetime.datetime(2017, 6, 1, 12, 22) friends=[1, 2, 3]
21 | print(user.id)
22 | # > 123
23 |
--------------------------------------------------------------------------------
/sugar/docs_src/python_types/tutorial011_py39.py:
--------------------------------------------------------------------------------
1 | from datetime import datetime
2 | from typing import Optional
3 |
4 | from pydantic import BaseModel
5 |
6 |
7 | class User(BaseModel):
8 | id: int
9 | name = "John Doe"
10 | signup_ts: Optional[datetime] = None
11 | friends: list[int] = []
12 |
13 |
14 | external_data = {
15 | "id": "123",
16 | "signup_ts": "2017-06-01 12:22",
17 | "friends": [1, "2", b"3"],
18 | }
19 | user = User(**external_data)
20 | print(user)
21 | # > User id=123 name='John Doe' signup_ts=datetime.datetime(2017, 6, 1, 12, 22) friends=[1, 2, 3]
22 | print(user.id)
23 | # > 123
24 |
--------------------------------------------------------------------------------
/sugar/docs_src/query_params/tutorial001.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 |
3 | app = FastAPI()
4 |
5 | fake_items_db = [{"item_name": "Foo"}, {"item_name": "Bar"}, {"item_name": "Baz"}]
6 |
7 |
8 | @app.get("/items/")
9 | async def read_item(skip: int = 0, limit: int = 10):
10 | return fake_items_db[skip : skip + limit]
11 |
--------------------------------------------------------------------------------
/sugar/docs_src/query_params/tutorial002.py:
--------------------------------------------------------------------------------
1 | from typing import Optional
2 |
3 | from fastapi import FastAPI
4 |
5 | app = FastAPI()
6 |
7 |
8 | @app.get("/items/{item_id}")
9 | async def read_item(item_id: str, q: Optional[str] = None):
10 | if q:
11 | return {"item_id": item_id, "q": q}
12 | return {"item_id": item_id}
13 |
--------------------------------------------------------------------------------
/sugar/docs_src/query_params/tutorial002_py310.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 |
3 | app = FastAPI()
4 |
5 |
6 | @app.get("/items/{item_id}")
7 | async def read_item(item_id: str, q: str | None = None):
8 | if q:
9 | return {"item_id": item_id, "q": q}
10 | return {"item_id": item_id}
11 |
--------------------------------------------------------------------------------
/sugar/docs_src/query_params/tutorial003.py:
--------------------------------------------------------------------------------
1 | from typing import Optional
2 |
3 | from fastapi import FastAPI
4 |
5 | app = FastAPI()
6 |
7 |
8 | @app.get("/items/{item_id}")
9 | async def read_item(item_id: str, q: Optional[str] = None, short: bool = False):
10 | item = {"item_id": item_id}
11 | if q:
12 | item.update({"q": q})
13 | if not short:
14 | item.update(
15 | {"description": "This is an amazing item that has a long description"}
16 | )
17 | return item
18 |
--------------------------------------------------------------------------------
/sugar/docs_src/query_params/tutorial003_py310.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 |
3 | app = FastAPI()
4 |
5 |
6 | @app.get("/items/{item_id}")
7 | async def read_item(item_id: str, q: str | None = None, short: bool = False):
8 | item = {"item_id": item_id}
9 | if q:
10 | item.update({"q": q})
11 | if not short:
12 | item.update(
13 | {"description": "This is an amazing item that has a long description"}
14 | )
15 | return item
16 |
--------------------------------------------------------------------------------
/sugar/docs_src/query_params/tutorial004.py:
--------------------------------------------------------------------------------
1 | from typing import Optional
2 |
3 | from fastapi import FastAPI
4 |
5 | app = FastAPI()
6 |
7 |
8 | @app.get("/users/{user_id}/items/{item_id}")
9 | async def read_user_item(
10 | user_id: int, item_id: str, q: Optional[str] = None, short: bool = False
11 | ):
12 | item = {"item_id": item_id, "owner_id": user_id}
13 | if q:
14 | item.update({"q": q})
15 | if not short:
16 | item.update(
17 | {"description": "This is an amazing item that has a long description"}
18 | )
19 | return item
20 |
--------------------------------------------------------------------------------
/sugar/docs_src/query_params/tutorial004_py310.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 |
3 | app = FastAPI()
4 |
5 |
6 | @app.get("/users/{user_id}/items/{item_id}")
7 | async def read_user_item(
8 | user_id: int, item_id: str, q: str | None = None, short: bool = False
9 | ):
10 | item = {"item_id": item_id, "owner_id": user_id}
11 | if q:
12 | item.update({"q": q})
13 | if not short:
14 | item.update(
15 | {"description": "This is an amazing item that has a long description"}
16 | )
17 | return item
18 |
--------------------------------------------------------------------------------
/sugar/docs_src/query_params/tutorial005.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 |
3 | app = FastAPI()
4 |
5 |
6 | @app.get("/items/{item_id}")
7 | async def read_user_item(item_id: str, needy: str):
8 | item = {"item_id": item_id, "needy": needy}
9 | return item
10 |
--------------------------------------------------------------------------------
/sugar/docs_src/query_params/tutorial006.py:
--------------------------------------------------------------------------------
1 | from typing import Optional
2 |
3 | from fastapi import FastAPI
4 |
5 | app = FastAPI()
6 |
7 |
8 | @app.get("/items/{item_id}")
9 | async def read_user_item(
10 | item_id: str, needy: str, skip: int = 0, limit: Optional[int] = None
11 | ):
12 | item = {"item_id": item_id, "needy": needy, "skip": skip, "limit": limit}
13 | return item
14 |
--------------------------------------------------------------------------------
/sugar/docs_src/query_params/tutorial006_py310.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 |
3 | app = FastAPI()
4 |
5 |
6 | @app.get("/items/{item_id}")
7 | async def read_user_item(
8 | item_id: str, needy: str, skip: int = 0, limit: int | None = None
9 | ):
10 | item = {"item_id": item_id, "needy": needy, "skip": skip, "limit": limit}
11 | return item
12 |
--------------------------------------------------------------------------------
/sugar/docs_src/query_params/tutorial006b.py:
--------------------------------------------------------------------------------
1 | from typing import Union
2 |
3 | from fastapi import FastAPI
4 |
5 | app = FastAPI()
6 |
7 |
8 | @app.get("/items/{item_id}")
9 | async def read_user_item(
10 | item_id: str, needy: str, skip: int = 0, limit: Union[int, None] = None
11 | ):
12 | item = {"item_id": item_id, "needy": needy, "skip": skip, "limit": limit}
13 | return item
14 |
--------------------------------------------------------------------------------
/sugar/docs_src/query_params_str_validations/tutorial001.py:
--------------------------------------------------------------------------------
1 | from typing import Optional
2 |
3 | from fastapi import FastAPI
4 |
5 | app = FastAPI()
6 |
7 |
8 | @app.get("/items/")
9 | async def read_items(q: Optional[str] = None):
10 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]}
11 | if q:
12 | results.update({"q": q})
13 | return results
14 |
--------------------------------------------------------------------------------
/sugar/docs_src/query_params_str_validations/tutorial001_py310.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 |
3 | app = FastAPI()
4 |
5 |
6 | @app.get("/items/")
7 | async def read_items(q: str | None = None):
8 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]}
9 | if q:
10 | results.update({"q": q})
11 | return results
12 |
--------------------------------------------------------------------------------
/sugar/docs_src/query_params_str_validations/tutorial002.py:
--------------------------------------------------------------------------------
1 | from typing import Optional
2 |
3 | from fastapi import FastAPI, Query
4 |
5 | app = FastAPI()
6 |
7 |
8 | @app.get("/items/")
9 | async def read_items(q: Optional[str] = Query(None, max_length=50)):
10 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]}
11 | if q:
12 | results.update({"q": q})
13 | return results
14 |
--------------------------------------------------------------------------------
/sugar/docs_src/query_params_str_validations/tutorial002_py310.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI, Query
2 |
3 | app = FastAPI()
4 |
5 |
6 | @app.get("/items/")
7 | async def read_items(q: str | None = Query(None, max_length=50)):
8 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]}
9 | if q:
10 | results.update({"q": q})
11 | return results
12 |
--------------------------------------------------------------------------------
/sugar/docs_src/query_params_str_validations/tutorial003.py:
--------------------------------------------------------------------------------
1 | from typing import Optional
2 |
3 | from fastapi import FastAPI, Query
4 |
5 | app = FastAPI()
6 |
7 |
8 | @app.get("/items/")
9 | async def read_items(q: Optional[str] = Query(None, min_length=3, max_length=50)):
10 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]}
11 | if q:
12 | results.update({"q": q})
13 | return results
14 |
--------------------------------------------------------------------------------
/sugar/docs_src/query_params_str_validations/tutorial003_py310.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI, Query
2 |
3 | app = FastAPI()
4 |
5 |
6 | @app.get("/items/")
7 | async def read_items(q: str | None = Query(None, min_length=3, max_length=50)):
8 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]}
9 | if q:
10 | results.update({"q": q})
11 | return results
12 |
--------------------------------------------------------------------------------
/sugar/docs_src/query_params_str_validations/tutorial004.py:
--------------------------------------------------------------------------------
1 | from typing import Optional
2 |
3 | from fastapi import FastAPI, Query
4 |
5 | app = FastAPI()
6 |
7 |
8 | @app.get("/items/")
9 | async def read_items(
10 | q: Optional[str] = Query(None, min_length=3, max_length=50, regex="^fixedquery$")
11 | ):
12 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]}
13 | if q:
14 | results.update({"q": q})
15 | return results
16 |
--------------------------------------------------------------------------------
/sugar/docs_src/query_params_str_validations/tutorial004_py310.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI, Query
2 |
3 | app = FastAPI()
4 |
5 |
6 | @app.get("/items/")
7 | async def read_items(
8 | q: str | None = Query(None, min_length=3, max_length=50, regex="^fixedquery$")
9 | ):
10 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]}
11 | if q:
12 | results.update({"q": q})
13 | return results
14 |
--------------------------------------------------------------------------------
/sugar/docs_src/query_params_str_validations/tutorial005.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI, Query
2 |
3 | app = FastAPI()
4 |
5 |
6 | @app.get("/items/")
7 | async def read_items(q: str = Query("fixedquery", min_length=3)):
8 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]}
9 | if q:
10 | results.update({"q": q})
11 | return results
12 |
--------------------------------------------------------------------------------
/sugar/docs_src/query_params_str_validations/tutorial006.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI, Query
2 |
3 | app = FastAPI()
4 |
5 |
6 | @app.get("/items/")
7 | async def read_items(q: str = Query(..., min_length=3)):
8 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]}
9 | if q:
10 | results.update({"q": q})
11 | return results
12 |
--------------------------------------------------------------------------------
/sugar/docs_src/query_params_str_validations/tutorial007.py:
--------------------------------------------------------------------------------
1 | from typing import Optional
2 |
3 | from fastapi import FastAPI, Query
4 |
5 | app = FastAPI()
6 |
7 |
8 | @app.get("/items/")
9 | async def read_items(
10 | q: Optional[str] = Query(None, title="Query string", min_length=3)
11 | ):
12 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]}
13 | if q:
14 | results.update({"q": q})
15 | return results
16 |
--------------------------------------------------------------------------------
/sugar/docs_src/query_params_str_validations/tutorial007_py310.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI, Query
2 |
3 | app = FastAPI()
4 |
5 |
6 | @app.get("/items/")
7 | async def read_items(q: str | None = Query(None, title="Query string", min_length=3)):
8 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]}
9 | if q:
10 | results.update({"q": q})
11 | return results
12 |
--------------------------------------------------------------------------------
/sugar/docs_src/query_params_str_validations/tutorial008.py:
--------------------------------------------------------------------------------
1 | from typing import Optional
2 |
3 | from fastapi import FastAPI, Query
4 |
5 | app = FastAPI()
6 |
7 |
8 | @app.get("/items/")
9 | async def read_items(
10 | q: Optional[str] = Query(
11 | None,
12 | title="Query string",
13 | description="Query string for the items to search in the database that have a good match",
14 | min_length=3,
15 | )
16 | ):
17 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]}
18 | if q:
19 | results.update({"q": q})
20 | return results
21 |
--------------------------------------------------------------------------------
/sugar/docs_src/query_params_str_validations/tutorial008_py310.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI, Query
2 |
3 | app = FastAPI()
4 |
5 |
6 | @app.get("/items/")
7 | async def read_items(
8 | q: str
9 | | None = Query(
10 | None,
11 | title="Query string",
12 | description="Query string for the items to search in the database that have a good match",
13 | min_length=3,
14 | )
15 | ):
16 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]}
17 | if q:
18 | results.update({"q": q})
19 | return results
20 |
--------------------------------------------------------------------------------
/sugar/docs_src/query_params_str_validations/tutorial009.py:
--------------------------------------------------------------------------------
1 | from typing import Optional
2 |
3 | from fastapi import FastAPI, Query
4 |
5 | app = FastAPI()
6 |
7 |
8 | @app.get("/items/")
9 | async def read_items(q: Optional[str] = Query(None, alias="item-query")):
10 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]}
11 | if q:
12 | results.update({"q": q})
13 | return results
14 |
--------------------------------------------------------------------------------
/sugar/docs_src/query_params_str_validations/tutorial009_py310.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI, Query
2 |
3 | app = FastAPI()
4 |
5 |
6 | @app.get("/items/")
7 | async def read_items(q: str | None = Query(None, alias="item-query")):
8 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]}
9 | if q:
10 | results.update({"q": q})
11 | return results
12 |
--------------------------------------------------------------------------------
/sugar/docs_src/query_params_str_validations/tutorial011.py:
--------------------------------------------------------------------------------
1 | from typing import List, Optional
2 |
3 | from fastapi import FastAPI, Query
4 |
5 | app = FastAPI()
6 |
7 |
8 | @app.get("/items/")
9 | async def read_items(q: Optional[List[str]] = Query(None)):
10 | query_items = {"q": q}
11 | return query_items
12 |
--------------------------------------------------------------------------------
/sugar/docs_src/query_params_str_validations/tutorial011_py310.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI, Query
2 |
3 | app = FastAPI()
4 |
5 |
6 | @app.get("/items/")
7 | async def read_items(q: list[str] | None = Query(None)):
8 | query_items = {"q": q}
9 | return query_items
10 |
--------------------------------------------------------------------------------
/sugar/docs_src/query_params_str_validations/tutorial011_py39.py:
--------------------------------------------------------------------------------
1 | from typing import Optional
2 |
3 | from fastapi import FastAPI, Query
4 |
5 | app = FastAPI()
6 |
7 |
8 | @app.get("/items/")
9 | async def read_items(q: Optional[list[str]] = Query(None)):
10 | query_items = {"q": q}
11 | return query_items
12 |
--------------------------------------------------------------------------------
/sugar/docs_src/query_params_str_validations/tutorial012.py:
--------------------------------------------------------------------------------
1 | from typing import List
2 |
3 | from fastapi import FastAPI, Query
4 |
5 | app = FastAPI()
6 |
7 |
8 | @app.get("/items/")
9 | async def read_items(q: List[str] = Query(["foo", "bar"])):
10 | query_items = {"q": q}
11 | return query_items
12 |
--------------------------------------------------------------------------------
/sugar/docs_src/query_params_str_validations/tutorial012_py39.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI, Query
2 |
3 | app = FastAPI()
4 |
5 |
6 | @app.get("/items/")
7 | async def read_items(q: list[str] = Query(["foo", "bar"])):
8 | query_items = {"q": q}
9 | return query_items
10 |
--------------------------------------------------------------------------------
/sugar/docs_src/query_params_str_validations/tutorial013.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI, Query
2 |
3 | app = FastAPI()
4 |
5 |
6 | @app.get("/items/")
7 | async def read_items(q: list = Query([])):
8 | query_items = {"q": q}
9 | return query_items
10 |
--------------------------------------------------------------------------------
/sugar/docs_src/request_files/tutorial001.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI, File, UploadFile
2 |
3 | app = FastAPI()
4 |
5 |
6 | @app.post("/files/")
7 | async def create_file(file: bytes = File(...)):
8 | return {"file_size": len(file)}
9 |
10 |
11 | @app.post("/uploadfile/")
12 | async def create_upload_file(file: UploadFile = File(...)):
13 | return {"filename": file.filename}
14 |
--------------------------------------------------------------------------------
/sugar/docs_src/request_forms/tutorial001.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI, Form
2 |
3 | app = FastAPI()
4 |
5 |
6 | @app.post("/login/")
7 | async def login(username: str = Form(...), password: str = Form(...)):
8 | return {"username": username}
9 |
--------------------------------------------------------------------------------
/sugar/docs_src/request_forms_and_files/tutorial001.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI, File, Form, UploadFile
2 |
3 | app = FastAPI()
4 |
5 |
6 | @app.post("/files/")
7 | async def create_file(
8 | file: bytes = File(...), fileb: UploadFile = File(...), token: str = Form(...)
9 | ):
10 | return {
11 | "file_size": len(file),
12 | "token": token,
13 | "fileb_content_type": fileb.content_type,
14 | }
15 |
--------------------------------------------------------------------------------
/sugar/docs_src/response_change_status_code/tutorial001.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI, Response, status
2 |
3 | app = FastAPI()
4 |
5 | tasks = {"foo": "Listen to the Bar Fighters"}
6 |
7 |
8 | @app.put("/get-or-create-task/{task_id}", status_code=200)
9 | def get_or_create_task(task_id: str, response: Response):
10 | if task_id not in tasks:
11 | tasks[task_id] = "This didn't exist before"
12 | response.status_code = status.HTTP_201_CREATED
13 | return tasks[task_id]
14 |
--------------------------------------------------------------------------------
/sugar/docs_src/response_cookies/tutorial001.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 | from fastapi.responses import JSONResponse
3 |
4 | app = FastAPI()
5 |
6 |
7 | @app.post("/cookie/")
8 | def create_cookie():
9 | content = {"message": "Come to the dark side, we have cookies"}
10 | response = JSONResponse(content=content)
11 | response.set_cookie(key="fakesession", value="fake-cookie-session-value")
12 | return response
13 |
--------------------------------------------------------------------------------
/sugar/docs_src/response_cookies/tutorial002.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI, Response
2 |
3 | app = FastAPI()
4 |
5 |
6 | @app.post("/cookie-and-object/")
7 | def create_cookie(response: Response):
8 | response.set_cookie(key="fakesession", value="fake-cookie-session-value")
9 | return {"message": "Come to the dark side, we have cookies"}
10 |
--------------------------------------------------------------------------------
/sugar/docs_src/response_directly/tutorial001.py:
--------------------------------------------------------------------------------
1 | from datetime import datetime
2 | from typing import Optional
3 |
4 | from fastapi import FastAPI
5 | from fastapi.encoders import jsonable_encoder
6 | from fastapi.responses import JSONResponse
7 | from pydantic import BaseModel
8 |
9 |
10 | class Item(BaseModel):
11 | title: str
12 | timestamp: datetime
13 | description: Optional[str] = None
14 |
15 |
16 | app = FastAPI()
17 |
18 |
19 | @app.put("/items/{id}")
20 | def update_item(id: str, item: Item):
21 | json_compatible_item_data = jsonable_encoder(item)
22 | return JSONResponse(content=json_compatible_item_data)
23 |
--------------------------------------------------------------------------------
/sugar/docs_src/response_directly/tutorial002.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI, Response
2 |
3 | app = FastAPI()
4 |
5 |
6 | @app.get("/legacy/")
7 | def get_legacy_data():
8 | data = """
9 |
10 |
11 | Apply shampoo here.
12 |
13 |
14 | You'll have to use soap here.
15 |
16 |
17 | """
18 | return Response(content=data, media_type="application/xml")
19 |
--------------------------------------------------------------------------------
/sugar/docs_src/response_headers/tutorial001.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 | from fastapi.responses import JSONResponse
3 |
4 | app = FastAPI()
5 |
6 |
7 | @app.get("/headers/")
8 | def get_headers():
9 | content = {"message": "Hello World"}
10 | headers = {"X-Cat-Dog": "alone in the world", "Content-Language": "en-US"}
11 | return JSONResponse(content=content, headers=headers)
12 |
--------------------------------------------------------------------------------
/sugar/docs_src/response_headers/tutorial002.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI, Response
2 |
3 | app = FastAPI()
4 |
5 |
6 | @app.get("/headers-and-object/")
7 | def get_headers(response: Response):
8 | response.headers["X-Cat-Dog"] = "alone in the world"
9 | return {"message": "Hello World"}
10 |
--------------------------------------------------------------------------------
/sugar/docs_src/response_model/tutorial001.py:
--------------------------------------------------------------------------------
1 | from typing import List, Optional
2 |
3 | from fastapi import FastAPI
4 | from pydantic import BaseModel
5 |
6 | app = FastAPI()
7 |
8 |
9 | class Item(BaseModel):
10 | name: str
11 | description: Optional[str] = None
12 | price: float
13 | tax: Optional[float] = None
14 | tags: List[str] = []
15 |
16 |
17 | @app.post("/items/", response_model=Item)
18 | async def create_item(item: Item):
19 | return item
20 |
--------------------------------------------------------------------------------
/sugar/docs_src/response_model/tutorial001_py310.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 | from pydantic import BaseModel
3 |
4 | app = FastAPI()
5 |
6 |
7 | class Item(BaseModel):
8 | name: str
9 | description: str | None = None
10 | price: float
11 | tax: float | None = None
12 | tags: list[str] = []
13 |
14 |
15 | @app.post("/items/", response_model=Item)
16 | async def create_item(item: Item):
17 | return item
18 |
--------------------------------------------------------------------------------
/sugar/docs_src/response_model/tutorial001_py39.py:
--------------------------------------------------------------------------------
1 | from typing import Optional
2 |
3 | from fastapi import FastAPI
4 | from pydantic import BaseModel
5 |
6 | app = FastAPI()
7 |
8 |
9 | class Item(BaseModel):
10 | name: str
11 | description: Optional[str] = None
12 | price: float
13 | tax: Optional[float] = None
14 | tags: list[str] = []
15 |
16 |
17 | @app.post("/items/", response_model=Item)
18 | async def create_item(item: Item):
19 | return item
20 |
--------------------------------------------------------------------------------
/sugar/docs_src/response_model/tutorial002.py:
--------------------------------------------------------------------------------
1 | from typing import Optional
2 |
3 | from fastapi import FastAPI
4 | from pydantic import BaseModel, EmailStr
5 |
6 | app = FastAPI()
7 |
8 |
9 | class UserIn(BaseModel):
10 | username: str
11 | password: str
12 | email: EmailStr
13 | full_name: Optional[str] = None
14 |
15 |
16 | # Don't do this in production!
17 | @app.post("/user/", response_model=UserIn)
18 | async def create_user(user: UserIn):
19 | return user
20 |
--------------------------------------------------------------------------------
/sugar/docs_src/response_model/tutorial002_py310.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 | from pydantic import BaseModel, EmailStr
3 |
4 | app = FastAPI()
5 |
6 |
7 | class UserIn(BaseModel):
8 | username: str
9 | password: str
10 | email: EmailStr
11 | full_name: str | None = None
12 |
13 |
14 | # Don't do this in production!
15 | @app.post("/user/", response_model=UserIn)
16 | async def create_user(user: UserIn):
17 | return user
18 |
--------------------------------------------------------------------------------
/sugar/docs_src/response_model/tutorial003.py:
--------------------------------------------------------------------------------
1 | from typing import Optional
2 |
3 | from fastapi import FastAPI
4 | from pydantic import BaseModel, EmailStr
5 |
6 | app = FastAPI()
7 |
8 |
9 | class UserIn(BaseModel):
10 | username: str
11 | password: str
12 | email: EmailStr
13 | full_name: Optional[str] = None
14 |
15 |
16 | class UserOut(BaseModel):
17 | username: str
18 | email: EmailStr
19 | full_name: Optional[str] = None
20 |
21 |
22 | @app.post("/user/", response_model=UserOut)
23 | async def create_user(user: UserIn):
24 | return user
25 |
--------------------------------------------------------------------------------
/sugar/docs_src/response_model/tutorial003_py310.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 | from pydantic import BaseModel, EmailStr
3 |
4 | app = FastAPI()
5 |
6 |
7 | class UserIn(BaseModel):
8 | username: str
9 | password: str
10 | email: EmailStr
11 | full_name: str | None = None
12 |
13 |
14 | class UserOut(BaseModel):
15 | username: str
16 | email: EmailStr
17 | full_name: str | None = None
18 |
19 |
20 | @app.post("/user/", response_model=UserOut)
21 | async def create_user(user: UserIn):
22 | return user
23 |
--------------------------------------------------------------------------------
/sugar/docs_src/response_status_code/tutorial001.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 |
3 | app = FastAPI()
4 |
5 |
6 | @app.post("/items/", status_code=201)
7 | async def create_item(name: str):
8 | return {"name": name}
9 |
--------------------------------------------------------------------------------
/sugar/docs_src/response_status_code/tutorial002.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI, status
2 |
3 | app = FastAPI()
4 |
5 |
6 | @app.post("/items/", status_code=status.HTTP_201_CREATED)
7 | async def create_item(name: str):
8 | return {"name": name}
9 |
--------------------------------------------------------------------------------
/sugar/docs_src/schema_extra_example/tutorial002.py:
--------------------------------------------------------------------------------
1 | from typing import Optional
2 |
3 | from fastapi import FastAPI
4 | from pydantic import BaseModel, Field
5 |
6 | app = FastAPI()
7 |
8 |
9 | class Item(BaseModel):
10 | name: str = Field(..., example="Foo")
11 | description: Optional[str] = Field(None, example="A very nice Item")
12 | price: float = Field(..., example=35.4)
13 | tax: Optional[float] = Field(None, example=3.2)
14 |
15 |
16 | @app.put("/items/{item_id}")
17 | async def update_item(item_id: int, item: Item):
18 | results = {"item_id": item_id, "item": item}
19 | return results
20 |
--------------------------------------------------------------------------------
/sugar/docs_src/schema_extra_example/tutorial002_py310.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 | from pydantic import BaseModel, Field
3 |
4 | app = FastAPI()
5 |
6 |
7 | class Item(BaseModel):
8 | name: str = Field(..., example="Foo")
9 | description: str | None = Field(None, example="A very nice Item")
10 | price: float = Field(..., example=35.4)
11 | tax: float | None = Field(None, example=3.2)
12 |
13 |
14 | @app.put("/items/{item_id}")
15 | async def update_item(item_id: int, item: Item):
16 | results = {"item_id": item_id, "item": item}
17 | return results
18 |
--------------------------------------------------------------------------------
/sugar/docs_src/security/tutorial001.py:
--------------------------------------------------------------------------------
1 | from fastapi import Depends, FastAPI
2 | from fastapi.security import OAuth2PasswordBearer
3 |
4 | app = FastAPI()
5 |
6 | oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token")
7 |
8 |
9 | @app.get("/items/")
10 | async def read_items(token: str = Depends(oauth2_scheme)):
11 | return {"token": token}
12 |
--------------------------------------------------------------------------------
/sugar/docs_src/security/tutorial006.py:
--------------------------------------------------------------------------------
1 | from fastapi import Depends, FastAPI
2 | from fastapi.security import HTTPBasic, HTTPBasicCredentials
3 |
4 | app = FastAPI()
5 |
6 | security = HTTPBasic()
7 |
8 |
9 | @app.get("/users/me")
10 | def read_current_user(credentials: HTTPBasicCredentials = Depends(security)):
11 | return {"username": credentials.username, "password": credentials.password}
12 |
--------------------------------------------------------------------------------
/sugar/docs_src/settings/app01/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs_src/settings/app01/__init__.py
--------------------------------------------------------------------------------
/sugar/docs_src/settings/app01/config.py:
--------------------------------------------------------------------------------
1 | from pydantic import BaseSettings
2 |
3 |
4 | class Settings(BaseSettings):
5 | app_name: str = "Awesome API"
6 | admin_email: str
7 | items_per_user: int = 50
8 |
9 |
10 | settings = Settings()
11 |
--------------------------------------------------------------------------------
/sugar/docs_src/settings/app01/main.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 |
3 | from .config import settings
4 |
5 | app = FastAPI()
6 |
7 |
8 | @app.get("/info")
9 | async def info():
10 | return {
11 | "app_name": settings.app_name,
12 | "admin_email": settings.admin_email,
13 | "items_per_user": settings.items_per_user,
14 | }
15 |
--------------------------------------------------------------------------------
/sugar/docs_src/settings/app02/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs_src/settings/app02/__init__.py
--------------------------------------------------------------------------------
/sugar/docs_src/settings/app02/config.py:
--------------------------------------------------------------------------------
1 | from pydantic import BaseSettings
2 |
3 |
4 | class Settings(BaseSettings):
5 | app_name: str = "Awesome API"
6 | admin_email: str
7 | items_per_user: int = 50
8 |
--------------------------------------------------------------------------------
/sugar/docs_src/settings/app02/main.py:
--------------------------------------------------------------------------------
1 | from functools import lru_cache
2 |
3 | from fastapi import Depends, FastAPI
4 |
5 | from .config import Settings
6 |
7 | app = FastAPI()
8 |
9 |
10 | @lru_cache()
11 | def get_settings():
12 | return Settings()
13 |
14 |
15 | @app.get("/info")
16 | async def info(settings: Settings = Depends(get_settings)):
17 | return {
18 | "app_name": settings.app_name,
19 | "admin_email": settings.admin_email,
20 | "items_per_user": settings.items_per_user,
21 | }
22 |
--------------------------------------------------------------------------------
/sugar/docs_src/settings/app02/test_main.py:
--------------------------------------------------------------------------------
1 | from fastapi.testclient import TestClient
2 |
3 | from .config import Settings
4 | from .main import app, get_settings
5 |
6 | client = TestClient(app)
7 |
8 |
9 | def get_settings_override():
10 | return Settings(admin_email="testing_admin@example.com")
11 |
12 |
13 | app.dependency_overrides[get_settings] = get_settings_override
14 |
15 |
16 | def test_app():
17 | response = client.get("/info")
18 | data = response.json()
19 | assert data == {
20 | "app_name": "Awesome API",
21 | "admin_email": "testing_admin@example.com",
22 | "items_per_user": 50,
23 | }
24 |
--------------------------------------------------------------------------------
/sugar/docs_src/settings/app03/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs_src/settings/app03/__init__.py
--------------------------------------------------------------------------------
/sugar/docs_src/settings/app03/config.py:
--------------------------------------------------------------------------------
1 | from pydantic import BaseSettings
2 |
3 |
4 | class Settings(BaseSettings):
5 | app_name: str = "Awesome API"
6 | admin_email: str
7 | items_per_user: int = 50
8 |
9 | class Config:
10 | env_file = ".env"
11 |
--------------------------------------------------------------------------------
/sugar/docs_src/settings/app03/main.py:
--------------------------------------------------------------------------------
1 | from functools import lru_cache
2 |
3 | from fastapi import Depends, FastAPI
4 |
5 | from . import config
6 |
7 | app = FastAPI()
8 |
9 |
10 | @lru_cache()
11 | def get_settings():
12 | return config.Settings()
13 |
14 |
15 | @app.get("/info")
16 | async def info(settings: config.Settings = Depends(get_settings)):
17 | return {
18 | "app_name": settings.app_name,
19 | "admin_email": settings.admin_email,
20 | "items_per_user": settings.items_per_user,
21 | }
22 |
--------------------------------------------------------------------------------
/sugar/docs_src/settings/tutorial001.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 | from pydantic import BaseSettings
3 |
4 |
5 | class Settings(BaseSettings):
6 | app_name: str = "Awesome API"
7 | admin_email: str
8 | items_per_user: int = 50
9 |
10 |
11 | settings = Settings()
12 | app = FastAPI()
13 |
14 |
15 | @app.get("/info")
16 | async def info():
17 | return {
18 | "app_name": settings.app_name,
19 | "admin_email": settings.admin_email,
20 | "items_per_user": settings.items_per_user,
21 | }
22 |
--------------------------------------------------------------------------------
/sugar/docs_src/sql_databases/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs_src/sql_databases/__init__.py
--------------------------------------------------------------------------------
/sugar/docs_src/sql_databases/sql_app/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs_src/sql_databases/sql_app/__init__.py
--------------------------------------------------------------------------------
/sugar/docs_src/sql_databases/sql_app/database.py:
--------------------------------------------------------------------------------
1 | from sqlalchemy import create_engine
2 | from sqlalchemy.ext.declarative import declarative_base
3 | from sqlalchemy.orm import sessionmaker
4 |
5 | SQLALCHEMY_DATABASE_URL = "sqlite:///./sql_app.db"
6 | # SQLALCHEMY_DATABASE_URL = "postgresql://user:password@postgresserver/db"
7 |
8 | engine = create_engine(
9 | SQLALCHEMY_DATABASE_URL, connect_args={"check_same_thread": False}
10 | )
11 | SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
12 |
13 | Base = declarative_base()
14 |
--------------------------------------------------------------------------------
/sugar/docs_src/sql_databases/sql_app/tests/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs_src/sql_databases/sql_app/tests/__init__.py
--------------------------------------------------------------------------------
/sugar/docs_src/sql_databases/sql_app_py310/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs_src/sql_databases/sql_app_py310/__init__.py
--------------------------------------------------------------------------------
/sugar/docs_src/sql_databases/sql_app_py310/database.py:
--------------------------------------------------------------------------------
1 | from sqlalchemy import create_engine
2 | from sqlalchemy.ext.declarative import declarative_base
3 | from sqlalchemy.orm import sessionmaker
4 |
5 | SQLALCHEMY_DATABASE_URL = "sqlite:///./sql_app.db"
6 | # SQLALCHEMY_DATABASE_URL = "postgresql://user:password@postgresserver/db"
7 |
8 | engine = create_engine(
9 | SQLALCHEMY_DATABASE_URL, connect_args={"check_same_thread": False}
10 | )
11 | SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
12 |
13 | Base = declarative_base()
14 |
--------------------------------------------------------------------------------
/sugar/docs_src/sql_databases/sql_app_py310/tests/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs_src/sql_databases/sql_app_py310/tests/__init__.py
--------------------------------------------------------------------------------
/sugar/docs_src/sql_databases/sql_app_py39/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs_src/sql_databases/sql_app_py39/__init__.py
--------------------------------------------------------------------------------
/sugar/docs_src/sql_databases/sql_app_py39/database.py:
--------------------------------------------------------------------------------
1 | from sqlalchemy import create_engine
2 | from sqlalchemy.ext.declarative import declarative_base
3 | from sqlalchemy.orm import sessionmaker
4 |
5 | SQLALCHEMY_DATABASE_URL = "sqlite:///./sql_app.db"
6 | # SQLALCHEMY_DATABASE_URL = "postgresql://user:password@postgresserver/db"
7 |
8 | engine = create_engine(
9 | SQLALCHEMY_DATABASE_URL, connect_args={"check_same_thread": False}
10 | )
11 | SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
12 |
13 | Base = declarative_base()
14 |
--------------------------------------------------------------------------------
/sugar/docs_src/sql_databases/sql_app_py39/tests/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs_src/sql_databases/sql_app_py39/tests/__init__.py
--------------------------------------------------------------------------------
/sugar/docs_src/sql_databases_peewee/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs_src/sql_databases_peewee/__init__.py
--------------------------------------------------------------------------------
/sugar/docs_src/sql_databases_peewee/sql_app/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs_src/sql_databases_peewee/sql_app/__init__.py
--------------------------------------------------------------------------------
/sugar/docs_src/sql_databases_peewee/sql_app/models.py:
--------------------------------------------------------------------------------
1 | import peewee
2 |
3 | from .database import db
4 |
5 |
6 | class User(peewee.Model):
7 | email = peewee.CharField(unique=True, index=True)
8 | hashed_password = peewee.CharField()
9 | is_active = peewee.BooleanField(default=True)
10 |
11 | class Meta:
12 | database = db
13 |
14 |
15 | class Item(peewee.Model):
16 | title = peewee.CharField(index=True)
17 | description = peewee.CharField(index=True)
18 | owner = peewee.ForeignKeyField(User, backref="items")
19 |
20 | class Meta:
21 | database = db
22 |
--------------------------------------------------------------------------------
/sugar/docs_src/static_files/tutorial001.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 | from fastapi.staticfiles import StaticFiles
3 |
4 | app = FastAPI()
5 |
6 | app.mount("/static", StaticFiles(directory="static"), name="static")
7 |
--------------------------------------------------------------------------------
/sugar/docs_src/sub_applications/tutorial001.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 |
3 | app = FastAPI()
4 |
5 |
6 | @app.get("/app")
7 | def read_main():
8 | return {"message": "Hello World from main app"}
9 |
10 |
11 | subapi = FastAPI()
12 |
13 |
14 | @subapi.get("/sub")
15 | def read_sub():
16 | return {"message": "Hello World from sub API"}
17 |
18 |
19 | app.mount("/subapi", subapi)
20 |
--------------------------------------------------------------------------------
/sugar/docs_src/templates/static/styles.css:
--------------------------------------------------------------------------------
1 | h1 {
2 | color: green;
3 | }
4 |
--------------------------------------------------------------------------------
/sugar/docs_src/templates/templates/item.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Item Details
4 |
5 |
6 |
7 | Item ID: {{ id }}
8 |
9 |
10 |
--------------------------------------------------------------------------------
/sugar/docs_src/templates/tutorial001.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI, Request
2 | from fastapi.responses import HTMLResponse
3 | from fastapi.staticfiles import StaticFiles
4 | from fastapi.templating import Jinja2Templates
5 |
6 | app = FastAPI()
7 |
8 | app.mount("/static", StaticFiles(directory="static"), name="static")
9 |
10 |
11 | templates = Jinja2Templates(directory="templates")
12 |
13 |
14 | @app.get("/items/{id}", response_class=HTMLResponse)
15 | async def read_item(request: Request, id: str):
16 | return templates.TemplateResponse("item.html", {"request": request, "id": id})
17 |
--------------------------------------------------------------------------------
/sugar/docs_src/using_request_directly/tutorial001.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI, Request
2 |
3 | app = FastAPI()
4 |
5 |
6 | @app.get("/items/{item_id}")
7 | def read_root(item_id: str, request: Request):
8 | client_host = request.client.host
9 | return {"client_host": client_host, "item_id": item_id}
10 |
--------------------------------------------------------------------------------
/sugar/docs_src/websockets/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/docs_src/websockets/__init__.py
--------------------------------------------------------------------------------
/sugar/docs_src/wsgi/tutorial001.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 | from fastapi.middleware.wsgi import WSGIMiddleware
3 | from flask import Flask, escape, request
4 |
5 | flask_app = Flask(__name__)
6 |
7 |
8 | @flask_app.route("/")
9 | def flask_main():
10 | name = request.args.get("name", "World")
11 | return f"Hello, {escape(name)} from Flask!"
12 |
13 |
14 | app = FastAPI()
15 |
16 |
17 | @app.get("/v2")
18 | def read_main():
19 | return {"message": "Hello World"}
20 |
21 |
22 | app.mount("/v1", WSGIMiddleware(flask_app))
23 |
--------------------------------------------------------------------------------
/sugar/scripts/build-docs.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | set -e
4 | set -x
5 |
6 | python ./scripts/docs.py build-all
7 |
--------------------------------------------------------------------------------
/sugar/scripts/clean.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh -e
2 |
3 | if [ -d 'dist' ] ; then
4 | rm -r dist
5 | fi
6 | if [ -d 'site' ] ; then
7 | rm -r site
8 | fi
9 |
--------------------------------------------------------------------------------
/sugar/scripts/docs-live.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | set -e
4 |
5 | mkdocs serve --dev-addr 0.0.0.0:8008
6 |
--------------------------------------------------------------------------------
/sugar/scripts/format.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh -e
2 | set -x
3 |
4 | autoflake --remove-all-unused-imports --recursive --remove-unused-variables --in-place docs_src fastapi tests scripts --exclude=__init__.py
5 | black fastapi tests docs_src scripts
6 | isort fastapi tests docs_src scripts
7 |
--------------------------------------------------------------------------------
/sugar/scripts/lint.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | set -e
4 | set -x
5 |
6 | mypy fastapi
7 | flake8 fastapi tests
8 | black fastapi tests --check
9 | isort fastapi tests docs_src scripts --check-only
10 |
--------------------------------------------------------------------------------
/sugar/scripts/netlify-docs.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | set -x
3 | set -e
4 | # Install pip
5 | cd /tmp
6 | curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
7 | python3.6 get-pip.py --user
8 | cd -
9 | # Install Flit to be able to install all
10 | python3.6 -m pip install --user flit
11 | # Install with Flit
12 | python3.6 -m flit install --user --extras doc
13 | # Finally, run mkdocs
14 | python3.6 -m mkdocs build
15 |
--------------------------------------------------------------------------------
/sugar/scripts/notify.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | set -e
4 |
5 | python scripts/gitter_releases_bot.py
6 |
--------------------------------------------------------------------------------
/sugar/scripts/publish.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | set -e
4 |
5 | flit publish
6 |
--------------------------------------------------------------------------------
/sugar/scripts/test-cov-html.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | set -e
4 | set -x
5 |
6 | bash scripts/test.sh --cov-report=html ${@}
7 |
--------------------------------------------------------------------------------
/sugar/scripts/test.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | set -e
4 | set -x
5 |
6 | # Check README.md is up to date
7 | python ./scripts/docs.py verify-readme
8 | export PYTHONPATH=./docs_src
9 | pytest --cov=fastapi --cov=tests --cov=docs_src --cov-report=term-missing:skip-covered --cov-report=xml tests ${@}
10 |
--------------------------------------------------------------------------------
/sugar/scripts/zip-docs.sh:
--------------------------------------------------------------------------------
1 | #! /usr/bin/env bash
2 |
3 | set -x
4 | set -e
5 |
6 | if [ -f docs.zip ]; then
7 | rm -rf docs.zip
8 | fi
9 | zip -r docs.zip ./site
10 |
--------------------------------------------------------------------------------
/sugar/tests/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/tests/__init__.py
--------------------------------------------------------------------------------
/sugar/tests/test_callable_endpoint.py:
--------------------------------------------------------------------------------
1 | from functools import partial
2 | from typing import Optional
3 |
4 | from fastapi import FastAPI
5 | from fastapi.testclient import TestClient
6 |
7 |
8 | def main(some_arg, q: Optional[str] = None):
9 | return {"some_arg": some_arg, "q": q}
10 |
11 |
12 | endpoint = partial(main, "foo")
13 |
14 | app = FastAPI()
15 |
16 | app.get("/")(endpoint)
17 |
18 |
19 | client = TestClient(app)
20 |
21 |
22 | def test_partial():
23 | response = client.get("/?q=bar")
24 | data = response.json()
25 | assert data == {"some_arg": "foo", "q": "bar"}
26 |
--------------------------------------------------------------------------------
/sugar/tests/test_include_route.py:
--------------------------------------------------------------------------------
1 | from fastapi import APIRouter, FastAPI, Request
2 | from fastapi.responses import JSONResponse
3 | from fastapi.testclient import TestClient
4 |
5 | app = FastAPI()
6 | router = APIRouter()
7 |
8 |
9 | @router.route("/items/")
10 | def read_items(request: Request):
11 | return JSONResponse({"hello": "world"})
12 |
13 |
14 | app.include_router(router)
15 |
16 | client = TestClient(app)
17 |
18 |
19 | def test_sub_router():
20 | response = client.get("/items/")
21 | assert response.status_code == 200, response.text
22 | assert response.json() == {"hello": "world"}
23 |
--------------------------------------------------------------------------------
/sugar/tests/test_modules_same_name_body/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/tests/test_modules_same_name_body/__init__.py
--------------------------------------------------------------------------------
/sugar/tests/test_modules_same_name_body/app/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/tests/test_modules_same_name_body/app/__init__.py
--------------------------------------------------------------------------------
/sugar/tests/test_modules_same_name_body/app/a.py:
--------------------------------------------------------------------------------
1 | from fastapi import APIRouter, Body
2 |
3 | router = APIRouter()
4 |
5 |
6 | @router.post("/compute")
7 | def compute(a: int = Body(...), b: str = Body(...)):
8 | return {"a": a, "b": b}
9 |
--------------------------------------------------------------------------------
/sugar/tests/test_modules_same_name_body/app/b.py:
--------------------------------------------------------------------------------
1 | from fastapi import APIRouter, Body
2 |
3 | router = APIRouter()
4 |
5 |
6 | @router.post("/compute/")
7 | def compute(a: int = Body(...), b: str = Body(...)):
8 | return {"a": a, "b": b}
9 |
--------------------------------------------------------------------------------
/sugar/tests/test_modules_same_name_body/app/main.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 |
3 | from . import a, b
4 |
5 | app = FastAPI()
6 |
7 | app.include_router(a.router, prefix="/a")
8 | app.include_router(b.router, prefix="/b")
9 |
--------------------------------------------------------------------------------
/sugar/tests/test_router_prefix_with_template.py:
--------------------------------------------------------------------------------
1 | from fastapi import APIRouter, FastAPI
2 | from fastapi.testclient import TestClient
3 |
4 | app = FastAPI()
5 |
6 | router = APIRouter()
7 |
8 |
9 | @router.get("/users/{id}")
10 | def read_user(segment: str, id: str):
11 | return {"segment": segment, "id": id}
12 |
13 |
14 | app.include_router(router, prefix="/{segment}")
15 |
16 |
17 | client = TestClient(app)
18 |
19 |
20 | def test_get():
21 | response = client.get("/seg/users/foo")
22 | assert response.status_code == 200, response.text
23 | assert response.json() == {"segment": "seg", "id": "foo"}
24 |
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/tests/test_tutorial/__init__.py
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_additional_responses/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/tests/test_tutorial/test_additional_responses/__init__.py
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_additional_status_codes/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/tests/test_tutorial/test_additional_status_codes/__init__.py
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_advanced_middleware/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/tests/test_tutorial/test_advanced_middleware/__init__.py
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_advanced_middleware/test_tutorial001.py:
--------------------------------------------------------------------------------
1 | from fastapi.testclient import TestClient
2 |
3 | from docs_src.advanced_middleware.tutorial001 import app
4 |
5 |
6 | def test_middleware():
7 | client = TestClient(app, base_url="https://testserver")
8 | response = client.get("/")
9 | assert response.status_code == 200, response.text
10 |
11 | client = TestClient(app)
12 | response = client.get("/", allow_redirects=False)
13 | assert response.status_code == 307, response.text
14 | assert response.headers["location"] == "https://testserver/"
15 |
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_async_sql_databases/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/tests/test_tutorial/test_async_sql_databases/__init__.py
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_async_tests/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/tests/test_tutorial/test_async_tests/__init__.py
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_async_tests/test_main.py:
--------------------------------------------------------------------------------
1 | import pytest
2 |
3 | from docs_src.async_tests.test_main import test_root
4 |
5 |
6 | @pytest.mark.anyio
7 | async def test_async_testing():
8 | await test_root()
9 |
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_background_tasks/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/tests/test_tutorial/test_background_tasks/__init__.py
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_behind_a_proxy/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/tests/test_tutorial/test_behind_a_proxy/__init__.py
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_bigger_applications/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/tests/test_tutorial/test_bigger_applications/__init__.py
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_body/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/tests/test_tutorial/test_body/__init__.py
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_body_fields/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/tests/test_tutorial/test_body_fields/__init__.py
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_body_multiple_params/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/tests/test_tutorial/test_body_multiple_params/__init__.py
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_body_nested_models/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/tests/test_tutorial/test_body_nested_models/__init__.py
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_body_updates/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/tests/test_tutorial/test_body_updates/__init__.py
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_conditional_openapi/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/tests/test_tutorial/test_conditional_openapi/__init__.py
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_cookie_params/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/tests/test_tutorial/test_cookie_params/__init__.py
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_cors/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/tests/test_tutorial/test_cors/__init__.py
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_custom_request_and_route/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/tests/test_tutorial/test_custom_request_and_route/__init__.py
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_custom_response/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/tests/test_tutorial/test_custom_response/__init__.py
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_custom_response/test_tutorial007.py:
--------------------------------------------------------------------------------
1 | from fastapi.testclient import TestClient
2 |
3 | from docs_src.custom_response.tutorial007 import app
4 |
5 | client = TestClient(app)
6 |
7 |
8 | def test_get():
9 | fake_content = b"some fake video bytes"
10 | response = client.get("/")
11 | assert response.content == fake_content * 10
12 |
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_custom_response/test_tutorial008.py:
--------------------------------------------------------------------------------
1 | from pathlib import Path
2 |
3 | from fastapi.testclient import TestClient
4 |
5 | from docs_src.custom_response import tutorial008
6 | from docs_src.custom_response.tutorial008 import app
7 |
8 | client = TestClient(app)
9 |
10 |
11 | def test_get(tmp_path: Path):
12 | file_path: Path = tmp_path / "large-video-file.mp4"
13 | tutorial008.some_file_path = str(file_path)
14 | test_content = b"Fake video bytes"
15 | file_path.write_bytes(test_content)
16 | response = client.get("/")
17 | assert response.content == test_content
18 |
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_custom_response/test_tutorial009.py:
--------------------------------------------------------------------------------
1 | from pathlib import Path
2 |
3 | from fastapi.testclient import TestClient
4 |
5 | from docs_src.custom_response import tutorial009
6 | from docs_src.custom_response.tutorial009 import app
7 |
8 | client = TestClient(app)
9 |
10 |
11 | def test_get(tmp_path: Path):
12 | file_path: Path = tmp_path / "large-video-file.mp4"
13 | tutorial009.some_file_path = str(file_path)
14 | test_content = b"Fake video bytes"
15 | file_path.write_bytes(test_content)
16 | response = client.get("/")
17 | assert response.content == test_content
18 |
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_custom_response/test_tutorial009b.py:
--------------------------------------------------------------------------------
1 | from pathlib import Path
2 |
3 | from fastapi.testclient import TestClient
4 |
5 | from docs_src.custom_response import tutorial009b
6 | from docs_src.custom_response.tutorial009b import app
7 |
8 | client = TestClient(app)
9 |
10 |
11 | def test_get(tmp_path: Path):
12 | file_path: Path = tmp_path / "large-video-file.mp4"
13 | tutorial009b.some_file_path = str(file_path)
14 | test_content = b"Fake video bytes"
15 | file_path.write_bytes(test_content)
16 | response = client.get("/")
17 | assert response.content == test_content
18 |
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_dependencies/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/tests/test_tutorial/test_dependencies/__init__.py
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_events/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/tests/test_tutorial/test_events/__init__.py
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_extending_openapi/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/tests/test_tutorial/test_extending_openapi/__init__.py
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_extra_data_types/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/tests/test_tutorial/test_extra_data_types/__init__.py
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_extra_models/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/tests/test_tutorial/test_extra_models/__init__.py
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_first_steps/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/tests/test_tutorial/test_first_steps/__init__.py
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_handling_errors/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/tests/test_tutorial/test_handling_errors/__init__.py
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_header_params/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/tests/test_tutorial/test_header_params/__init__.py
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_metadata/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/tests/test_tutorial/test_metadata/__init__.py
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_openapi_callbacks/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/tests/test_tutorial/test_openapi_callbacks/__init__.py
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_path_operation_advanced_configurations/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/tests/test_tutorial/test_path_operation_advanced_configurations/__init__.py
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_path_operation_configurations/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/tests/test_tutorial/test_path_operation_configurations/__init__.py
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_path_params/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/tests/test_tutorial/test_path_params/__init__.py
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_query_params/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/tests/test_tutorial/test_query_params/__init__.py
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_query_params_str_validations/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/tests/test_tutorial/test_query_params_str_validations/__init__.py
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_request_files/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/tests/test_tutorial/test_request_files/__init__.py
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_request_forms/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/tests/test_tutorial/test_request_forms/__init__.py
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_request_forms_and_files/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/tests/test_tutorial/test_request_forms_and_files/__init__.py
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_response_change_status_code/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/tests/test_tutorial/test_response_change_status_code/__init__.py
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_response_change_status_code/test_tutorial001.py:
--------------------------------------------------------------------------------
1 | from fastapi.testclient import TestClient
2 |
3 | from docs_src.response_change_status_code.tutorial001 import app
4 |
5 | client = TestClient(app)
6 |
7 |
8 | def test_path_operation():
9 | response = client.put("/get-or-create-task/foo")
10 | print(response.content)
11 | assert response.status_code == 200, response.text
12 | assert response.json() == "Listen to the Bar Fighters"
13 | response = client.put("/get-or-create-task/bar")
14 | assert response.status_code == 201, response.text
15 | assert response.json() == "This didn't exist before"
16 |
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_response_cookies/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/tests/test_tutorial/test_response_cookies/__init__.py
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_response_cookies/test_tutorial001.py:
--------------------------------------------------------------------------------
1 | from fastapi.testclient import TestClient
2 |
3 | from docs_src.response_cookies.tutorial001 import app
4 |
5 | client = TestClient(app)
6 |
7 |
8 | def test_path_operation():
9 | response = client.post("/cookie/")
10 | assert response.status_code == 200, response.text
11 | assert response.json() == {"message": "Come to the dark side, we have cookies"}
12 | assert response.cookies["fakesession"] == "fake-cookie-session-value"
13 |
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_response_cookies/test_tutorial002.py:
--------------------------------------------------------------------------------
1 | from fastapi.testclient import TestClient
2 |
3 | from docs_src.response_cookies.tutorial002 import app
4 |
5 | client = TestClient(app)
6 |
7 |
8 | def test_path_operation():
9 | response = client.post("/cookie-and-object/")
10 | assert response.status_code == 200, response.text
11 | assert response.json() == {"message": "Come to the dark side, we have cookies"}
12 | assert response.cookies["fakesession"] == "fake-cookie-session-value"
13 |
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_response_headers/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/tests/test_tutorial/test_response_headers/__init__.py
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_response_headers/test_tutorial001.py:
--------------------------------------------------------------------------------
1 | from fastapi.testclient import TestClient
2 |
3 | from docs_src.response_headers.tutorial001 import app
4 |
5 | client = TestClient(app)
6 |
7 |
8 | def test_path_operation():
9 | response = client.get("/headers/")
10 | assert response.status_code == 200, response.text
11 | assert response.json() == {"message": "Hello World"}
12 | assert response.headers["X-Cat-Dog"] == "alone in the world"
13 | assert response.headers["Content-Language"] == "en-US"
14 |
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_response_headers/test_tutorial002.py:
--------------------------------------------------------------------------------
1 | from fastapi.testclient import TestClient
2 |
3 | from docs_src.response_headers.tutorial002 import app
4 |
5 | client = TestClient(app)
6 |
7 |
8 | def test_path_operation():
9 | response = client.get("/headers-and-object/")
10 | assert response.status_code == 200, response.text
11 | assert response.json() == {"message": "Hello World"}
12 | assert response.headers["X-Cat-Dog"] == "alone in the world"
13 |
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_response_model/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/tests/test_tutorial/test_response_model/__init__.py
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_schema_extra_example/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/tests/test_tutorial/test_schema_extra_example/__init__.py
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_security/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/tests/test_tutorial/test_security/__init__.py
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_settings/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/tests/test_tutorial/test_settings/__init__.py
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_settings/test_app02.py:
--------------------------------------------------------------------------------
1 | from fastapi.testclient import TestClient
2 | from pytest import MonkeyPatch
3 |
4 | from docs_src.settings.app02 import main, test_main
5 |
6 | client = TestClient(main.app)
7 |
8 |
9 | def test_settings(monkeypatch: MonkeyPatch):
10 | monkeypatch.setenv("ADMIN_EMAIL", "admin@example.com")
11 | settings = main.get_settings()
12 | assert settings.app_name == "Awesome API"
13 | assert settings.items_per_user == 50
14 |
15 |
16 | def test_override_settings():
17 | test_main.test_app()
18 |
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_sql_databases/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/tests/test_tutorial/test_sql_databases/__init__.py
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_sql_databases_peewee/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/tests/test_tutorial/test_sql_databases_peewee/__init__.py
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_sub_applications/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/tests/test_tutorial/test_sub_applications/__init__.py
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_templates/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/tests/test_tutorial/test_templates/__init__.py
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_testing/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/tests/test_tutorial/test_testing/__init__.py
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_testing/test_main_b.py:
--------------------------------------------------------------------------------
1 | from docs_src.app_testing.app_b import test_main
2 |
3 |
4 | def test_app():
5 | test_main.test_create_existing_item()
6 | test_main.test_create_item()
7 | test_main.test_create_item_bad_token()
8 | test_main.test_read_inexistent_item()
9 | test_main.test_read_item()
10 | test_main.test_read_item_bad_token()
11 |
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_testing/test_main_b_py310.py:
--------------------------------------------------------------------------------
1 | from ...utils import needs_py310
2 |
3 |
4 | @needs_py310
5 | def test_app():
6 | from docs_src.app_testing.app_b_py310 import test_main
7 |
8 | test_main.test_create_existing_item()
9 | test_main.test_create_item()
10 | test_main.test_create_item_bad_token()
11 | test_main.test_read_inexistent_item()
12 | test_main.test_read_item()
13 | test_main.test_read_item_bad_token()
14 |
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_testing/test_tutorial002.py:
--------------------------------------------------------------------------------
1 | from docs_src.app_testing.tutorial002 import test_read_main, test_websocket
2 |
3 |
4 | def test_main():
5 | test_read_main()
6 |
7 |
8 | def test_ws():
9 | test_websocket()
10 |
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_testing/test_tutorial003.py:
--------------------------------------------------------------------------------
1 | from docs_src.app_testing.tutorial003 import test_read_items
2 |
3 |
4 | def test_main():
5 | test_read_items()
6 |
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_testing_dependencies/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/tests/test_tutorial/test_testing_dependencies/__init__.py
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_websockets/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/tests/test_tutorial/test_websockets/__init__.py
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_wsgi/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RudyBekker/SuperSaaSFastAPI/b8dfe7fca31640869b44db06176d01751e05e5e5/sugar/tests/test_tutorial/test_wsgi/__init__.py
--------------------------------------------------------------------------------
/sugar/tests/test_tutorial/test_wsgi/test_tutorial001.py:
--------------------------------------------------------------------------------
1 | from fastapi.testclient import TestClient
2 |
3 | from docs_src.wsgi.tutorial001 import app
4 |
5 | client = TestClient(app)
6 |
7 |
8 | def test_flask():
9 | response = client.get("/v1/")
10 | assert response.status_code == 200, response.text
11 | assert response.text == "Hello, World from Flask!"
12 |
13 |
14 | def test_app():
15 | response = client.get("/v2")
16 | assert response.status_code == 200, response.text
17 | assert response.json() == {"message": "Hello World"}
18 |
--------------------------------------------------------------------------------
/sugar/tests/utils.py:
--------------------------------------------------------------------------------
1 | import sys
2 |
3 | import pytest
4 |
5 | needs_py37 = pytest.mark.skipif(sys.version_info < (3, 7), reason="requires python3.7+")
6 | needs_py39 = pytest.mark.skipif(sys.version_info < (3, 9), reason="requires python3.9+")
7 | needs_py310 = pytest.mark.skipif(
8 | sys.version_info < (3, 10), reason="requires python3.10+"
9 | )
10 |
--------------------------------------------------------------------------------