如何润到墙外→中国青年失业率真相→历史的伤口→白纸革命→四通桥事件→
墙内
*/
-#![feature(proc_macro_hygiene, decl_macro)]
+//#![feature(proc_macro_hygiene, decl_macro)]
use chrono::{TimeZone, Utc, NaiveDateTime};
}
}
}
+#[get("/")]
+fn index() -> String {
+ return "因為RSS來源提供的格式屢屢除錯,致常判讀錯誤,故此程式暫停運作。不便之處敬請見諒".to_string();
+}
-
+/*
#[get("/<stock_id>/json")]
fn get_tw_stock_json(stock_id: String) -> String {
let response_body = get_stock_data(stock_id.as_str(), Date::Day(1), Date::YearToDate);
let stock_main_data_json = serde_json::json!(stock_main_data);
- return stock_main_data_json.to_string();
+ //return stock_main_data_json.to_string();
+ return "000".to_string();
}
let rss_xml = get_rss_data(stock_id.as_str());
+ println!("~~~{:}", rss_xml);
+
//let rss_xml = fs::read_to_string("/tmp/a.rss")
// .expect("Should have been able to read the file");
let rss_parsed = parser::parse(rss_xml.as_bytes()).unwrap();
-
+ println!("qqqq");
let response_body = get_stock_data(stock_id.as_str(), Date::Day(1), Date::YearToDate);
+
+ println!("rrrr");
let response_json: Value = serde_json::from_str(response_body.as_str()).unwrap();
let mut stock_main_data = tw_stock_process_json(&response_json);
}
fn get_rss_data(stock_id : &str) -> String{
- let url = format!("https://tw.stock.yahoo.com/rss?s={:}",
+ let url = format!("https://tw.stock.yahoo.com/rss?s={:}.TW",
stock_id
);
-
-
- return get_url_data(&url);
+ let res = get_url_data(&url);
+ println!("{:}", res);
+ return res;
}
fn get_stock_data(stock_id: &str, interval: Date, range: Date) -> String {
stock_id, intrval_str, range_str
);
-
-
- return get_url_data(&url);
+ let res = get_url_data(&url);
+ println!("{:}", res);
+ return res;
}
fn get_url_data(url : &String) -> String{
})
.unwrap();
+
+
curl_transfer.perform().unwrap();
}
#[launch]
fn rocket() -> Rocket<Build> {
- // rocket::ignite().mount("/", routes![index]).launch();
+ //rocket::ignite().mount("/", routes![index]).launch();
rocket::build().attach(Template::fairing())
.mount("/tw", routes![get_tw_stock, get_tw_stock_json])
+}*/
+
+#[launch]
+fn rocket() -> Rocket<Build> {
+ rocket::build().mount("/", routes![index])
+
+
}
+