Giter Site home page Giter Site logo

toidiu / mta-status Goto Github PK

View Code? Open in Web Editor NEW
8.0 3.0 1.0 922 KB

parses mta xml response and return a nice json

License: MIT License

Rust 61.20% Makefile 3.43% JavaScript 7.93% Vue 26.83% Dockerfile 0.60%
rust hyper tokio tokio-rs server clippy raspberry-pi docker

mta-status's Introduction

Build Status

mta-status

mtaStatus is a REST API that returns MTA subway status in Json format.

It is written in Rust for all the wonderful reasons, but most importantly the fact that it results in a tiny service. The tiny runtime cost really shines when you deploy it on a raspberryPi, which has become my main source for testing and personal projects.

Why

The MTA is necessary if you live in NYC. It is also highly unreliable :| For this reason we need to keep an eye on which trains are running (especially for those early morning commutes).

  • Now you have the option of using the wonderful widget that is provided by the MTA: http://www.mta.info/mta-service-status-widget
  • Or maybe we like to view the status on our phones and the lack of a mobile site is annoying, so we look for an api: http://web.mta.info/status/serviceStatus.txt
  • YES that is XML!! But wait is that HTML embedded inside the XML?? YES!

Therefore the nice Json API.

Build

Build for Raspi:

Source https://github.com/Ragnaroek/rust-on-raspberry-docker

Run from the root project dir:

docker run \
    --volume $PWD:/home/cross/project \
    --volume ~/.cargo/registry:/home/cross/.cargo/registry \
    ragnaroek/rust-raspberry:1.23.0 build --release

copy executable onto your raspi scp -P 100 target/arm-unknown-linux-gnueabihf/release/mta_status [email protected]:mta_status

Build for Docker on x86:

make build

Other

Some commands:

  • cargo install cargo-watch
  • cargo watch -x 'rustc --bin mta-status --features clippy -- -Z no-trans' //assumes nightly(see Cargo.toml)
  • cargo watch -x 'rustc --lib --features clippy -- -Z no-trans' //assumes nightly(see Cargo.toml)
  • cargo watch -x run
  • cargo build --release

Private Docs

cargo rustdoc --lib --open -- --no-defaults --passes collapse-docs --passes unindent-comments --passes strip-priv-imports

Future work (PR's are welcome)

  • add better logging
  • add better error handling
  • don't hit the MTA server on each request and instead cache the response in a local file
  • implement the service as multi-threaded
  • logo
  • make a client to use the api :)

mta-status's People

Contributors

ivuk avatar toidiu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

ceache

mta-status's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.