Generate a backend and frontend stack using Python, including interactive API documentation.
README.md
.Go to the directory where you want to create your project and run:
pip install cookiecutter
cookiecutter https://github.com/tiangolo/full-stack-fastapi-postgresql
You will be asked to provide passwords and secret keys for several components. Open another terminal and run:
openssl rand -hex 32
# Outputs something like: 99d3b1f01aa639e4a76f4fc281fc834747a543720ba4c8a8648ba755aef9be7f
Copy the contents and use that as password / secret key. And run that again to generate another secure key.
The generator (cookiecutter) will ask you for some data, you might want to have at hand before generating the project.
The input variables, with their default values (some auto generated) are:
project_name
: The name of the project
project_slug
: The development friendly name of the project. By default, based on the project name
domain_main
: The domain in where to deploy the project for production (from the branch production
), used by the load balancer, backend, etc. By default, based on the project slug.
domain_staging
: The domain in where to deploy while staging (before production) (from the branch master
). By default, based on the main domain.
docker_swarm_stack_name_main
: The name of the stack while deploying to Docker in Swarm mode for production. By default, based on the domain.
docker_swarm_stack_name_staging
: The name of the stack while deploying to Docker in Swarm mode for staging. By default, based on the domain.
secret_key
: Backend server secret key. Use the method above to generate it.
first_superuser
: The first superuser generated, with it you will be able to create more users, etc. By default, based on the domain.
first_superuser_password
: First superuser password. Use the method above to generate it.
backend_cors_origins
: Origins (domains, more or less) that are enabled for CORS (Cross Origin Resource Sharing). This allows a frontend in one domain (e.g. https://dashboard.example.com
) to communicate with this backend, that could be living in another domain (e.g. https://api.example.com
). It can also be used to allow your local frontend (with a custom hosts
domain mapping, as described in the project's README.md
) that could be living in http://dev.example.com:8080
to communicate with the backend at https://stag.example.com
. Notice the http
vs https
and the dev.
prefix for local development vs the "staging" stag.
prefix. By default, it includes origins for production, staging and development, with ports commonly used during local development by several popular frontend frameworks (Vue with :8080
, React, Angular).
smtp_port
: Port to use to send emails via SMTP. By default 587
.
smtp_host
: Host to use to send emails, it would be given by your email provider, like Mailgun, Sparkpost, etc.
smtp_user
: The user to use in the SMTP connection. The value will be given by your email provider.
smtp_password
: The password to be used in the SMTP connection. The value will be given by the email provider.
smtp_emails_from_email
: The email account to use as the sender in the notification emails, it would be something like info@your-custom-domain.com
.
postgres_password
: Postgres database password. Use the method above to generate it. (You could easily modify it to use MySQL, MariaDB, etc).
pgadmin_default_user
: PGAdmin default user, to log-in to the PGAdmin interface.
pgadmin_default_user_password
: PGAdmin default user password. Generate it with the method above.
traefik_constraint_tag
: The tag to be used by the internal Traefik load balancer (for example, to divide requests between backend and frontend) for production. Used to separate this stack from any other stack you might have. This should identify each stack in each environment (production, staging, etc).
traefik_constraint_tag_staging
: The Traefik tag to be used while on staging.
traefik_public_constraint_tag
: The tag that should be used by stack services that should communicate with the public.
flower_auth
: Basic HTTP authentication for flower, in the formuser:password
. By default: "admin:changethis
".
sentry_dsn
: Key URL (DSN) of Sentry, for live error reporting. You can use the open source version or a free account. E.g.: https://1234abcd:5678ef@sentry.example.com/30
.
docker_image_prefix
: Prefix to use for Docker image names. If you are using GitLab Docker registry it would be based on your code repository. E.g.: git.example.com/development-team/my-awesome-project/
.
docker_image_backend
: Docker image name for the backend. By default, it will be based on your Docker image prefix, e.g.: git.example.com/development-team/my-awesome-project/backend
. And depending on your environment, a different tag will be appended ( prod
, stag
, branch
). So, the final image names used will be like: git.example.com/development-team/my-awesome-project/backend:prod
.
docker_image_celeryworker
: Docker image for the celery worker. By default, based on your Docker image prefix.
docker_image_frontend
: Docker image for the frontend. By default, based on your Docker image prefix.
This stack can be adjusted and used with several deployment options that are compatible with Docker Compose, but it is designed to be used in a cluster controlled with pure Docker in Swarm Mode with a Traefik main load balancer proxy handling automatic HTTPS certificates, using the ideas from DockerSwarm.rocks.
Please refer to DockerSwarm.rocks to see how to deploy such a cluster in 20 minutes.
After using this generator, your new project (the directory created) will contain an extensive README.md
with instructions for development, deployment, etc. You can pre-read the project README.md
template here too.
TestClient
. PR #160.yield
.sub
.docker-compose.*.yml
files, refactor deployment to reduce config files. PR #153..env
file. PR #151.traefik-public
as done in DockerSwarm.rocks, to simplify development and iteration of the project generator. PR #150.login
tag. PR #135 by @Nonameentered..
instead of source
for interoperability. PR #98 by @gucharbon.BaseSettings
for settings/configs and env vars. PR #87 by @StephenBrown2.package-lock.json
to let everyone lock their own versions (depending on OS, etc).read_item
and response code. PR #74 by @jcaguirre89.Fix security on resetting a password. Receive token as body, not query. PR #34.
Fix security on resetting a password. Receive it as body, not query. PR #33 by @dmontagu.
Fix SQLAlchemy class lookup on initialization. PR #29 by @ebreton.
Fix SQLAlchemy operation errors on database restart. PR #32 by @ebreton.
Fix locations of scripts in generated README. PR #19 by @ebreton.
Forward arguments from script to pytest
inside container. PR #17 by @ebreton.
Update development scripts.
Create DB Item objects from all Pydantic model's fields.
Update Jupyter Lab installation and util script/environment variable for local development.
PR #14:
UserInCreate
to UserCreate
, etc.include_router
.Upgrade Python to 3.7 as Celery is now compatible too. PR #10 by @ebreton.
Fix documentation for path operation to get user by ID. PR #4 by @mpclarkson in FastAPI.
Set /start-reload.sh
as a command override for development by default.
Update generated README.
Dockerfile
s.Several bug fixes since initial publication, including:
This project is licensed under the terms of the MIT license.
1、打开/etc/hosts 文件,添加: 199.232.68.133 raw.githubusercontent.com 2、打开项目目录下docker-compose.yml文件,添加: extra_hosts: - "raw.githubusercontent.com:199.232.68.133" version: "3.3" services: prox
1、设置postgresql数据库密码: su - gitlab-psql psql -h /var/opt/gitlab/postgresql -d gitlabhq_production \password gitlab 编辑 /etc/gitlab/gitlab.rb 修改下面内容 gitlab_rails[‘db_password’] = ‘这个就是你刚刚在Postgresql中设置的密码
FastAPI SqlAlchemy MySql表迁移 本系列博客是配合Vue开发一套后台管理系统,对应的Vue教程见个人博客 https://www.charmcode.cn/ FastAPI项目官网是直接使用的SqlAlchemy ORM,不像Flask,一般使用Flask-SqlAlchemy扩展,习惯了flask扩展的,没使用 SqlAlchemy, 虽然大体上很像,但是有些地方还是不一样
原文:https://fastapi.tiangolo.com/alternatives/ 作者:tiangolo,FastAPI 的创作者,github star 10.1k 翻译:somenzz 侵删 本文讲述了什么启发了 FastAPI 的诞生,它与其他替代框架的对比,以及从中汲取的经验。 简介 如果不是基于前人的成果,FastAPI 将不会存在。在 FastAPI 之前,前人已经创建了许多
fastapi发表时间:2020-03-09 最新的变化¶0.52.0¶使用添加新的高性能JSON响应类orjson。新文档:自定义响应-HTML,流,文件等:ORJSONResponse。PR#1065。0.5-1.0¶从Starlette重新导出实用程序:这样就可以使用from fastapi.responses import JSONResponse代替之类的东西from starlette
Full Stack Flask and PostgreSQL - Base Project Generator Generate a backend and frontend stack using Python, including interactive API documentation. Notice: Flask or FastAPI If you are using this pro
Full-Stack-Notes 一个处于萌芽阶段的知识库,用于持续分享自己的所见、所学、所思! 点击切换详细目录 ☕ JAVA Java 反射与注解 Java 并发编程 Java NIO 核心组件详解 Java 函数式编程 Java 设计模式 Java 虚拟机 JVM 性能监控之命令行工具 JVM 性能监控之可视化工具 Tomcat 架构解析 Java 集合类源码解析 �� 网络基础 计算机网络
Full-Stack Roadmap 2021 This is a repository holding information and resources for everyone interested in becoming a Full-Stack Web Developer in 2021. As you can see, this stack is a bit biased as I c
Angular Full Stack Angular Full Stack is a project to easly get started with the latest Angular using a real backend and database. Whole stack is in TypeScript, from frontend to backend, giving you th
Full Reactive Stack This repository contains backend and frontend projects that make use of Reactive Web patterns,as explained in the mini book Full Reactive Stack with Spring Boot 2, WebFlux, MongoDB
This codebase goes along with the tutorial The Complete Guide to Full Stack Ethereum Development The video course for this codebase is located here Getting started Here's how to deploy this project Cl