# rust_actix_tera_postgres 演示 **Repository Path**: sice5921/rust_actix_tera_postgres ## Basic Information - **Project Name**: rust_actix_tera_postgres 演示 - **Description**: 非常基础的笔记,新手记录。 - **Primary Language**: Rust - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 2 - **Created**: 2020-09-08 - **Last Updated**: 2023-10-31 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # rust_actix_tera_postgres 演示 #### 介绍 非常基础的笔记,新手记录。 #### 参考 1. [actic-web examples](https://github.com/actix/examples) 2. [basics](https://github.com/actix/examples/basics) 3. [sqlx_todo](https://github.com/actix/examples/sqlx_todo) 4. [template_tera](https://github.com/actix/examples/template_tera) #### 安装教程 1. 在根目录下创建 ".env" 文件,内容如下: ``` HOST=127.0.0.1 PORT=5000 DATABASE_URL="postgres://username:password@server_addr/database_name" # 日志显示方式,生产环境可以注释此条 #RUST_LOG=sqlx_todo=info,actix=info # 不知道为什么用这一句不显示自己写的info内容 RUST_LOG="info" # 模板路径 TEMPLATES_DIR="templates/**/*" ``` 2. 在 postgresql 数据库创建表 ``` CREATE TABLE IF NOT EXISTS todos ( id SERIAL PRIMARY KEY, description TEXT NOT NULL, done BOOLEAN NOT NULL DEFAULT FALSE ); ``` #### 使用教程 1. ```cargo run``` 2. 访问 ```http://127.0.0.1/examples/welcome``` #### 遗留问题 目前还不知道怎么统一处理错误, 比如访问 http://127.0.0.1/sssss ,可以经p404处理 但是访问 http://127.0.0.1/static ,只能显示 无法访问网页