diff --git a/Readme.md b/Readme.md new file mode 100644 index 0000000..f0b2050 --- /dev/null +++ b/Readme.md @@ -0,0 +1,19 @@ +Theme : Travelling + +API's USED : +https://indianrailapi.com/api/v2/AllTrainOnStation + +https://indianrailapi.com/api/v2/TrainSchedule + +*PROBLEM STATEMENT* + +Whenever we are in a rush to visit any place, often the primary approach to most of the Indian community would be railways. Railways provide decent services at reduced costs which is more preferable compared to any other means of transport. But, what if the buffer time between booking tickets and the actual date of train travel is less than a week? That's where the problem starts, in such situations, you cannot find a suitable direct point-to-point train that picks you from your city and drops you at the desired location. Such trains usually have their tickets sold out if you check a week before the scheduled travel day. + +*SOLUTION* + +When you don't find a suitable direct train from your source to your destination, you pick a station in between and try to find trains till that point and from there to your final destination. We designed an algorithm that helps you pick a station in between the source and destination. Considering that station we find trains that go till the station and from the station to your final destination. + + +*Working* + +The algorithm takes two inputs from the user i.e the station code of his/her source and destination. From these inputs, we find that long train's route whose tickets would be most probably sold out. We monitor the stop time of this train at each platform and then determine a station to be vast if it has a larger stop time. Optimizing furthermore, we select only such stations that fall under 40%-70% of the total distance so that a station nearer to the source or destination is not selected. From here on we get to find the trains that let us reach the middle station selected with the algorithm and give us suitable options to get there easily, saving time. diff --git a/app.js b/app.js new file mode 100644 index 0000000..2d469c0 --- /dev/null +++ b/app.js @@ -0,0 +1,31 @@ +const express = require('express'); +const request = require('request'); +const hbs = require('hbs'); +const bodyparser = require('body-parser'); +const app =express(); +const path = require('path'); + +const port = process.env.PORT || 3000; +app.use(bodyparser.json()); +app.use(bodyparser.urlencoded({ extended: false })) + +app.use(express.static(path.join(__dirname,'public'))); + +app.set('views',path.join(__dirname,'templates/views')); +app.set('view engine','hbs'); + +app.use(express.urlencoded({extended: true})); +app.use(express.json()); + +app.get('/', function(req,res){ + // res.render('index'); + res.render('homescreen') +}); + +app.use('/auth',require('./routes/auth')); + +app.listen(port,()=>{ + console.log(`servewr is on port ${port}`); +}); + +module.exports = app; \ No newline at end of file diff --git a/auth.js b/auth.js new file mode 100644 index 0000000..94cc470 --- /dev/null +++ b/auth.js @@ -0,0 +1,145 @@ +const express = require('express'); +const router = express.Router(); +const bcrypt = require('bcryptjs') +const request = require('request'); +const { json } = require('express'); + +router.post('/check',function(req,res) +{ + var source = req.body.from; + var destination = req.body.to; + console.log(source); + console.log(destination); + + _External_URL = `https://indianrailapi.com/api/v2/AllTrainOnStation/apikey/72a4b65e030c0f6316343d8564fe3e34/StationCode/${source}/`; + request(_External_URL , {json: true}, (err,res,body) => { + if(err) + { + console.log(err); + } + else + { + const trainsFromStation = body; + var trainnumberlist = []; + var k=0; + for(var i=0;i { + if(err1) + { + console.log(err); + } + else + { + const trainStationsList = body1.Route; + var soudis; + var destdis; + for(var qq=0;qq= lowestdistance && trainStationsList[m].Distance <= maximumdistance) + { + possiblestation[mm]=trainStationsList[m].StationCode; + var timefirst = trainStationsList[m].ArrivalTime; + var timesecond = trainStationsList[m].DepartureTime; + var af = timefirst.split(':'); // split it at the colons + var bf = timesecond.split(':'); + var minutesfirst = (+af[0]) * 60 + (+af[1]); + var minutesecond = (+bf[0]) * 60 + (+bf[1]); + possiblestationtime[mm] = (minutesecond-minutesfirst); + mm++; + } + } + for (var inn=0; inn < mm-1; inn++) + { + for ( var jn = 0; jn < mm-inn-1; jn++) + { + if (possiblestationtime[jn] > possiblestationtime[jn+1]) + { + var temp = possiblestationtime[jn]; + possiblestationtime[jn] = possiblestationtime[jn+1]; + possiblestationtime[jn+1]=temp; + + var tempn = possiblestation[jn]; + possiblestation[jn] = possiblestation[jn+1]; + possiblestation[jn+1]=tempn; + } + } + } + console.log(possiblestation); + console.log(possiblestationtime); + for(var stt = mm-1;stt>=0;stt--) + { + var findtrain = possiblestation[stt]; + for(var ilt=0;ilt { + if(err2) + { + console.log(err2); + } + else + { + const trainsFromMid = body2; + const trainsmidlist=[]; + var s=0; + for(var ilt1=0;ilt1 + + + + + + Document + + +
+

Login Form

+ +
+ + + + + + + + + + + + \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..61c024b --- /dev/null +++ b/index.html @@ -0,0 +1,51 @@ + + + + + RailConnect + +
+
+

RAIL-CONNECT

+
+ +
+ +
+
+
+
+
+ + +
+
+ + +
+ +
+
+
+
+
+
+

OUTPUT

+
+
+
+
+ + + + \ No newline at end of file diff --git a/styles.css b/styles.css new file mode 100644 index 0000000..bf17a3b --- /dev/null +++ b/styles.css @@ -0,0 +1,78 @@ +header { + text-align: left; + padding: 15px; + background-color: #3aafa9; + color: white; +} +.header-title{ + font-size: 30px; + font-weight: 600; + text-align: left; + padding-left: 30px; +} +body{ + background-color: rgb(255, 255, 255); + font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif; +} +.container{ + height: 450px; + width: 500px; + margin: auto; + max-width: 90%; + max-height: 90%; +} +.container form{ + font-size: 25px ; + font-weight: 600; + height: 80%; + width: 80%; + padding : 30px; + background:white; + border-radius: 4px; + box-shadow: 0,8px,16px rgba(0, 0, 0, 0.3); +} +.container form .form-control{ + width:100%; + height: 40px; + background:white; + border: 1px solid silver ; + border-radius: 4px; + margin: 10px 0 18px 0; + padding : 0 10px; +} +.column { + float: left; + width: 40%; + padding: 0 10px; +} +.row { + margin: 0 -5px; +} +.row:after { + content: ""; + display: table; + clear: both; +} +.container form .btn{ + font-size: 30px ; + font-weight: 600; + margin-left:50%; + margin-top: 10%; + transform:translateX(-50%); + width: 120px; + height: 34px; + border: none; + outline : none; + background:#3aafa9; + cursor:pointer; + font-size: 16px; + color :white; + border-radius: 4px; + transition: .3s; +} +footer { + text-align: center; + padding: 3px; + background-color: #3aafa9; + color: white; +} \ No newline at end of file