small changes to server code
This commit is contained in:
commit
c6cf81a583
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,3 +2,4 @@
|
|||||||
Cargo.lock
|
Cargo.lock
|
||||||
/database/database.sqlite
|
/database/database.sqlite
|
||||||
/NEA_Screenshots
|
/NEA_Screenshots
|
||||||
|
.DS_Store
|
23
src/main.rs
23
src/main.rs
@ -1,6 +1,6 @@
|
|||||||
// relevant macros and imports for rocket.rs
|
// relevant macros and imports for rocket.rs
|
||||||
#[macro_use] extern crate rocket;
|
#[macro_use] extern crate rocket;
|
||||||
use rocket::{Rocket, Build, fs::{FileServer, relative}, serde::{Deserialize, json::Json}};
|
use rocket::{Rocket, Build, fs::{FileServer, relative}, serde::{Deserialize, json::Json}, Error, Response};
|
||||||
pub mod sql;
|
pub mod sql;
|
||||||
|
|
||||||
#[get("/")]
|
#[get("/")]
|
||||||
@ -14,28 +14,17 @@ fn test() -> String {
|
|||||||
#[serde(crate = "rocket::serde")]
|
#[serde(crate = "rocket::serde")]
|
||||||
struct PostTest<'r> {
|
struct PostTest<'r> {
|
||||||
test_type: &'r str,
|
test_type: &'r str,
|
||||||
test_length: i64,
|
test_length: u32,
|
||||||
test_time: i32,
|
test_time: u32,
|
||||||
test_seed: i64,
|
test_seed: i64,
|
||||||
quote_id: i32,
|
quote_id: i32,
|
||||||
wpm: i16,
|
wpm: u8,
|
||||||
accuracy: i8,
|
accuracy: u8,
|
||||||
user_id: i32
|
user_id: u32
|
||||||
}
|
}
|
||||||
|
|
||||||
#[post("/post_test", data = "<test>")]
|
#[post("/post_test", data = "<test>")]
|
||||||
fn post_test(test: Json<PostTest<'_>>) {
|
fn post_test(test: Json<PostTest<'_>>) {
|
||||||
println!(
|
|
||||||
"{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}",
|
|
||||||
test.test_type,
|
|
||||||
test.test_length,
|
|
||||||
test.test_time,
|
|
||||||
test.test_seed,
|
|
||||||
test.quote_id,
|
|
||||||
test.wpm,
|
|
||||||
test.accuracy,
|
|
||||||
test.user_id
|
|
||||||
);
|
|
||||||
sql::post_test(test.test_type, test.test_length, test.test_time, test.test_seed, test.quote_id, test.wpm, test.accuracy, test.user_id)
|
sql::post_test(test.test_type, test.test_length, test.test_time, test.test_seed, test.quote_id, test.wpm, test.accuracy, test.user_id)
|
||||||
.expect("error in posting test to tests table");
|
.expect("error in posting test to tests table");
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ pub fn create_database() -> Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn post_test(test_type: &str, test_length: i64, test_time: i32, test_seed: i64, quote_id: i32, wpm: i16, accuracy: i8, user_id: i32)
|
pub fn post_test(test_type: &str, test_length: u32, test_time: u32, test_seed: i64, quote_id: i32, wpm: u8, accuracy: u8, user_id: u32)
|
||||||
-> Result<()> {
|
-> Result<()> {
|
||||||
let connection = get_connection();
|
let connection = get_connection();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user