https://github.com/noracodes/rfortune
A Rust quotation webapp built using Rocket
https://github.com/noracodes/rfortune
Last synced: over 1 year ago
JSON representation
A Rust quotation webapp built using Rocket
- Host: GitHub
- URL: https://github.com/noracodes/rfortune
- Owner: NoraCodes
- License: agpl-3.0
- Created: 2017-01-04T00:38:49.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2023-06-07T21:17:18.000Z (about 3 years ago)
- Last Synced: 2025-03-30T17:04:37.067Z (over 1 year ago)
- Language: Rust
- Homepage:
- Size: 129 KB
- Stars: 9
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# rfortune
A simple Rust `fortune`-like webapp with Rocket

## What
This simple webapp reads quotes from a SQLite database and picks a random one to return
with each request. It uses templates for HTML responses and `serde` for JSON.
It provides a proof of concept for my use of Rocket.
What this application demonstrates:
- [x] Database with `rusqlite`
- [x] Templates with `tera`
- [x] JSON API with `serde` and the `rocket_contrib` JSON support
- [x] Integrated command line management
- [x] Form data entry
- [x] Responsive, mobile-first design
- [x] Custom error pages
- [x] Rust 2018 compliance
- [ ] Rocket tests
## Why
I like Rocket, as a concept. It allows me to use Rust, a language that tends to
produce code which is both fast and correct, as a backend for services which
typically need to be both fast and correct - web services.
Rocket also works with paradigms I'm familiar with: pluggable datastore and
template modules connected by route functions, like Flask.
## How
To run the application, simply clone the repo and, assuming that you have
a nightly Rust toolchain installed, as well as `libsqlite3-dev`, run
`cargo run` in the root directory - you'll get a webserver running!
You'll need to add quotes using either `cargo run add dev.db [source]`
or the JSON API.
## License
This software is subject to the terms of the GNU Affero General Public License v3.0.