Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created PR for merging food app #52

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
141 changes: 141 additions & 0 deletions day1/demo1_trial.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title></title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="2022.6">
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; line-height: 20.0px; font: 12.0px '.AppleSystemUIFontMonospaced'; color: #bdc6d0; -webkit-text-stroke: #bdc6d0}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; line-height: 20.0px; font: 12.0px '.AppleSystemUIFontMonospaced'; color: #bdc6d0; -webkit-text-stroke: #bdc6d0; min-height: 15.0px}
p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; text-align: right; line-height: 20.0px; font: 12.0px '.AppleSystemUIFontMonospaced'; color: #bdc6d0; -webkit-text-stroke: #bdc6d0; min-height: 15.0px}
span.s1 {font-kerning: none}
table.t1 {background-color: #0c0e12; border-collapse: collapse}
td.td1 {width: 64.5px; padding: 0.0px 10.0px 0.0px 10.0px}
td.td2 {width: 331.6px; padding: 0.0px 10.0px 0.0px 10.0px}
td.td3 {width: 64.5px; min-width: 50.0px; padding: 0.0px 10.0px 0.0px 10.0px}
</style>
</head>
<body>
<table cellspacing="0" cellpadding="0" class="t1">
<tbody>
<tr>
<td valign="top" class="td1">
<p class="p1"><span class="s1">&lt;html&gt;</span></p>
</td>
</tr>
<tr>
<td valign="top" class="td2">
<p class="p2"><span class="s1"></span><br></p>
<p class="p2"><span class="s1"></span><br></p>
</td>
</tr>
<tr>
<td valign="top" class="td3">
<p class="p3"><span class="s1"></span><br></p>
</td>
<td valign="top" class="td2">
<p class="p1"><span class="s1">&lt;head&gt;</span></p>
</td>
</tr>
<tr>
<td valign="top" class="td3">
<p class="p3"><span class="s1"></span><br></p>
</td>
<td valign="top" class="td2">
<p class="p1"><span class="s1"><span class="Apple-converted-space">    </span>&lt;title&gt;demofile 1&lt;/title&gt;</span></p>
</td>
</tr>
<tr>
<td valign="top" class="td3">
<p class="p3"><span class="s1"></span><br></p>
</td>
<td valign="top" class="td2">
<p class="p1"><span class="s1">&lt;/head&gt;</span></p>
</td>
</tr>
<tr>
<td valign="top" class="td2">
<p class="p2"><span class="s1"></span><br></p>
<p class="p2"><span class="s1"></span><br></p>
</td>
</tr>
<tr>
<td valign="top" class="td3">
<p class="p3"><span class="s1"></span><br></p>
</td>
<td valign="top" class="td2">
<p class="p1"><span class="s1">&lt;body&gt;</span></p>
</td>
</tr>
<tr>
<td valign="top" class="td3">
<p class="p3"><span class="s1"></span><br></p>
</td>
<td valign="top" class="td2">
<p class="p1"><span class="s1"><span class="Apple-converted-space">        </span>&lt;h1&gt;Swiggy batch 2 I++ program&lt;/h1&gt;</span></p>
</td>
</tr>
<tr>
<td valign="top" class="td3">
<p class="p3"><span class="s1"></span><br></p>
</td>
<td valign="top" class="td2">
<p class="p1"><span class="s1"><span class="Apple-converted-space">        </span>&lt;h2&gt;Just testing it&lt;/h2&gt;</span></p>
</td>
</tr>
<tr>
<td valign="top" class="td2">
<p class="p2"><span class="s1"></span><br></p>
<p class="p2"><span class="s1"></span><br></p>
</td>
</tr>
<tr>
<td valign="top" class="td3">
<p class="p3"><span class="s1"></span><br></p>
</td>
<td valign="top" class="td2">
<p class="p2"><span class="s1"><span class="Apple-converted-space">    </span></span></p>
</td>
</tr>
<tr>
<td valign="top" class="td3">
<p class="p3"><span class="s1"></span><br></p>
</td>
<td valign="top" class="td2">
<p class="p2"><span class="s1"></span><br></p>
</td>
</tr>
<tr>
<td valign="top" class="td2">
<p class="p2"><span class="s1"></span><br></p>
<p class="p2"><span class="s1"></span><br></p>
</td>
</tr>
<tr>
<td valign="top" class="td3">
<p class="p3"><span class="s1"></span><br></p>
</td>
<td valign="top" class="td2">
<p class="p1"><span class="s1">&lt;/body&gt;</span></p>
</td>
</tr>
<tr>
<td valign="top" class="td2">
<p class="p2"><span class="s1"></span><br></p>
<p class="p2"><span class="s1"></span><br></p>
</td>
</tr>
<tr>
<td valign="top" class="td3">
<p class="p3"><span class="s1"></span><br></p>
</td>
<td valign="top" class="td2">
<p class="p1"><span class="s1">&lt;/html&gt;</span></p>
</td>
</tr>
</tbody>
</table>
</body>
</html>
91 changes: 91 additions & 0 deletions day1/marks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// Declare an array which contains 5 different subject marks
// Find sum, min, max and print them all
// Print marks and iterate it
// Count of pass and fail

marks = [66,43, 59, 82, 98];

sum_total=0;
min_marks=100;
max_marks=0;
count_pass=0;
count_fail=0;

for (let i=0; i < marks.length; i++) {
sum_total += marks[i];
max_marks = Math.max(max_marks,marks[i])
min_marks = Math.min(min_marks,marks[i])
if(marks[i]<50)
{
count_fail++;
}
else count_pass++;
}

console.log("Total marks: ", sum_total);
console.log("Minimum marks: ", min_marks);
console.log("Maximum marks: ", max_marks);
console.log("Count of failed subjects: ", count_fail);
console.log("Count of passed subjects: ", count_pass);


function demo(){
console.log("Welcome to the batch 2");
}
demo()

function Welcome(name){
console.log(`Welcome ${name} to camp`)
}
Welcome("Viewer")
Welcome("Spectator")


function calc(val1, val2)
{
return val1+val2;
}
console.log(calc(100,200))


function sumval()
{
sum = 0;
for(i = 0; i < arguments.length; i++)
{
sum+=arguments[i];
}
return sum;
}

console.log(sumval(1,5,6))

const callback = function(){
sum = 0;
for(i = 0; arguments.length; i++)
{
sum = sum +arguments[i];
}
return sum;
}
function caller(fun_param)
{
return fun_param(1,2,3);
}

const addtwo = (a, b) => {
return a + b;
}

function numfunc(a, b) {
return a+b;
}
const arrowshorter = (a, b) => a+b;

console.log(arrowshorter(1,4));
console.log(numfunc(1,4));
console.log(addtwo(1,4));

(function(name){
console.log(name);
})("Just for fun");
16 changes: 16 additions & 0 deletions day2/evenodd.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<script>
function evenOrOdd(x){
if(x%2==0)
{
console.log("%d is even", + x);
}
else{
console.log("%d is odd", + x);
}
}
evenOrOdd(9);
evenOrOdd(22);
const input = prompt("Enter number: ");
console.log(evenOrOdd(${input}));

</script>
12 changes: 12 additions & 0 deletions day4/log.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
var log = {
info:function(info){
console.log('Info: ' + info);
},
warning:function(warning){
console.log('Warning: ' + warning);
},
error:function(error){
console.log('Error: ' + error);
}
};
module.exports = log
25 changes: 25 additions & 0 deletions day4/mongo-db-connect.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const { MongoClient } = require("mongodb");
const url = 'mongodb://localhost:27017/';
const db_name = "sample_db_new";

MongoClient.connect(url,(err,client)=>{
if(!err){
console.log("connected!")
}else{
console.log("Not connected...Error in connecting")
}
})

/*
const {MongoClient} = require("mongodb");
const url = 'mongodb://localhost:27017/';
const db_name = "sampledb";
MongoClient.connect(url, { useNewUrlParser: true }, (err, client) => {
if (!err) {
console.log("connected succesfully");
} else {
console.log("Could not connnect");
}
});

*/
2 changes: 2 additions & 0 deletions day4/my-script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
var myLogs = require('./log.js')
myLogs.info("app started")
8 changes: 8 additions & 0 deletions day4/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
var http = require('http')
var server = http.createServer(function(req,res){
console.log("request received")
res.writeHead(200,{'Content-Type':'text/html'})
res.write('<html><body><h1> Hi welcome to NodeJS!</h1></body></html>')
res.end();
})
server.listen(8081);
13 changes: 13 additions & 0 deletions day4/server1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
var express = require("express")

var app = express();

app.get("/users/get_all_users",(req,res)=>{
res.send("all users list will be listed soon...");
})

var server = app.listen(8888,function(){
var host = server.address().address;
var port = server.address().port;
console.log("app listening at http://%s:%s ",host,port);
});
3 changes: 3 additions & 0 deletions food-app-api/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
package-lock.json
.env
Binary file added food-app-api/Problem_Statement_2_Food_App.pdf
Binary file not shown.
35 changes: 35 additions & 0 deletions food-app-api/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Batch 2 : Swiggy i++

## Author: Shriyadita Roy

## Food App API

The "Food App" is a web application that facilitates users to order food online from different restaurants using the web-app to cater their needs. This solution has been built in accordance to the [second problem statement](batch-2/food-app-api/Problem_Statement_2_Food_App.pdf) out of given 3 problem statements for Swiggy i++. This app uses Node and Express to handle backend API endpoints, with MongoDB as the database.

### Requirements to run in local system

1. node.js
2. MongoDB

### Usage

To use the app locally in your system, follow these steps:

1. Clone the source folder **food-app-api**
2. Open a terminal in the same directory.
3. Run `npm install`.
4. If aforementioned command runs successfully, then run `npm start`. Do not close this window unless you want to shut down the Food App.
5. Use [localhost:8000](https://localhost:8000) domain for testing all API endpoints.

>#### User routes:
>* [/api/register [POST]](https://localhost:8000/api/register)
>* [/api/authenticate [POST]](https://localhost:8000/api/authenticate)
>* [/api/users [GET]](https://localhost:8000/api/users)
>* [/api/users/:userID [GET]](https://localhost:8000/api/users/)
>* [/api/users/:userID [PUT]](https://localhost:8000/api/users/test1)
>* [/api/users/:userID [DELETE]](https://localhost:8000/api/users/test1)


>#### Food routes:
>* [/api/food/ [POST]](https://localhost:8000/api/food)
>* [/api/food/:foodID [GET]](https://localhost:8000/api/food/1)
6 changes: 6 additions & 0 deletions food-app-api/food.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"foodId": 99,
"foodName": "Veg Fried Rice",
"foodCost": 120,
"foodType": "Chinese"
}
28 changes: 28 additions & 0 deletions food-app-api/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const express = require('express');
const mongoose = require('mongoose');
const bodyParser = require('body-parser');
require('dotenv/config');

const app = express();

app.get('/', (req, res) => {
res.send("Welcome to the Food App!");
});

const usersRoute = require('./routes/users');
const foodRoute = require('./routes/food');

app.use(bodyParser.json());
app.use(usersRoute);
app.use(foodRoute)

//const url = 'mongodb://127.0.0.1:27017/food-app'
const url = process.env.DB_URL || DB_URL;
mongoose.connect(url, () => console.log('Connected to DB!'));


//const PORT = 8000;
const port = process.env.API_PORT || API_PORT;
app.listen(port, () => {
console.log(`Server is running on port ${port}`);
});
Loading