1
0
mirror of https://github.com/actix/examples synced 2025-02-02 09:39:03 +01:00
examples/basics/todo/README.md

50 lines
1.1 KiB
Markdown
Raw Normal View History

2018-08-27 10:56:26 +01:00
# actix-todo
A port of the [Rocket Todo example](https://github.com/SergioBenitez/Rocket/tree/master/examples/todo) into [actix-web](https://actix.rs/). Except this uses PostgreSQL instead of SQLite.
# Usage
## Prerequisites
* Rust >= 1.26
* PostgreSQL >= 9.5
## Change into the project sub-directory
All instructions assume you have changed into this folder:
```bash
cd basics/todo
2018-08-27 10:56:26 +01:00
```
## Set up the database
2022-02-05 17:34:43 +00:00
Install the [sqlx](https://github.com/launchbadge/sqlx) command-line tool including the `postgres` feature:
2018-08-27 10:56:26 +01:00
```bash
2022-02-05 17:34:43 +00:00
cargo install sqlx-cli --no-default-features --features postgres
2018-08-27 10:56:26 +01:00
```
Check the contents of the `.env` file. If your database requires a password, update `DATABASE_URL` to be of the form:
```.env
2022-02-05 17:34:43 +00:00
DATABASE_URL=postgres://username:password@localhost:5432/actix_todo
2018-08-27 10:56:26 +01:00
```
Then to create and set-up the database run:
```bash
2022-02-05 17:34:43 +00:00
sqlx database create
sqlx migrate run
2018-08-27 10:56:26 +01:00
```
## Run the application
To run the application execute:
```bash
cargo run
```
2022-02-05 17:34:43 +00:00
Then to view it in your browser navigate to: [http://localhost:8088/](http://localhost:8088/)