-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
1,113 additions
and
79 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Tracking Form</title> | ||
<style> | ||
body { | ||
font-family: Arial, sans-serif; | ||
background-color: #f2f2f2; | ||
} | ||
|
||
.container { | ||
max-width: 400px; | ||
margin: 0 auto; | ||
padding: 20px; | ||
background-color: #fff; | ||
border-radius: 5px; | ||
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); | ||
} | ||
|
||
h1 { | ||
text-align: center; | ||
color: #333; | ||
} | ||
|
||
form { | ||
margin-top: 20px; | ||
} | ||
|
||
label { | ||
display: block; | ||
margin-bottom: 10px; | ||
color: #555; | ||
} | ||
|
||
input[type="text"] { | ||
width: 100%; | ||
padding: 10px; | ||
border: 1px solid #ccc; | ||
border-radius: 4px; | ||
} | ||
|
||
input[type="submit"] { | ||
width: 100%; | ||
padding: 10px; | ||
background-color: #4CAF50; | ||
color: #fff; | ||
border: none; | ||
border-radius: 4px; | ||
cursor: pointer; | ||
} | ||
|
||
input[type="submit"]:hover { | ||
background-color: #45a049; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<h1>Tantalizing Thursday treat tracker</h1> | ||
<form action="/id" method="post"> | ||
<label for="tracking-url">Tracking URL:</label> | ||
<input type="text" id="tracking-url" name="tracking-url" required> | ||
<input type="submit" value="Submit"> | ||
</form> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use std::{error, io::Cursor, thread}; | ||
|
||
use tide::Request; | ||
use tokio::runtime::Runtime; | ||
|
||
pub fn setup() { | ||
thread::spawn(move || Runtime::new().unwrap().block_on(food_endpoint_server())); | ||
} | ||
|
||
async fn food_endpoint_server() -> tide::Result<()> { | ||
let mut app = tide::new(); | ||
app.at("/id").post(get_tracking_ID); | ||
app.at("/").serve_file("src/food/index.html")?; | ||
app.listen("127.0.0.1:1337").await?; | ||
Ok(()) | ||
} | ||
|
||
async fn get_tracking_ID(mut req: Request<()>) -> tide::Result { | ||
Ok(format!("Food!").into()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
use serde_derive::Deserialize; | ||
use serde_derive::Serialize; | ||
|
||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct Root { | ||
pub status: String, | ||
#[serde(rename = "preorder_status")] | ||
pub preorder_status: String, | ||
#[serde(rename = "from_location")] | ||
pub from_location: FromLocation, | ||
#[serde(rename = "to_location")] | ||
pub to_location: ToLocation, | ||
pub couriers: Vec<Courier>, | ||
#[serde(rename = "pre_estimate")] | ||
pub pre_estimate: String, | ||
#[serde(rename = "delivery_eta")] | ||
pub delivery_eta: String, | ||
#[serde(rename = "pickup_eta")] | ||
pub pickup_eta: String, | ||
#[serde(rename = "requested_dropoff_time")] | ||
pub requested_dropoff_time: String, | ||
#[serde(rename = "refresh_in_seconds")] | ||
pub refresh_in_seconds: i64, | ||
} | ||
|
||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct FromLocation { | ||
pub coordinates: Coordinates, | ||
pub name: Name, | ||
} | ||
|
||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct Coordinates { | ||
pub lat: f64, | ||
pub lon: f64, | ||
} | ||
|
||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct Name { | ||
pub en: String, | ||
} | ||
|
||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct ToLocation { | ||
pub coordinates: Coordinates2, | ||
} | ||
|
||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct Coordinates2 { | ||
pub lat: f64, | ||
pub lon: f64, | ||
} | ||
|
||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct Courier { | ||
pub id: String, | ||
pub coordinates: Coordinates3, | ||
#[serde(rename = "vehicle_type")] | ||
pub vehicle_type: String, | ||
#[serde(rename = "is_delivering")] | ||
pub is_delivering: bool, | ||
} | ||
|
||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct Coordinates3 { | ||
pub lat: f64, | ||
pub lon: f64, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters