mirror of
https://github.com/SrIzan10/YouRL.git
synced 2026-05-01 11:15:09 +00:00
connection to mongodb
using mongoose, no schema yet.
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>URL Shortner</h1>
|
||||
<form action="" method="POST" class="my-4 form-inline">
|
||||
<form action="shortUrls" method="POST" class="my-4 form-inline">
|
||||
<label for="fullurl" class="sr-only">URL</label>
|
||||
<input
|
||||
required
|
||||
|
||||
1
models/README.md
Normal file
1
models/README.md
Normal file
@@ -0,0 +1 @@
|
||||
model to store all the urls and information
|
||||
13
server.js
13
server.js
@@ -1,16 +1,25 @@
|
||||
//web framework
|
||||
const express = require("express");
|
||||
|
||||
//make basic app
|
||||
|
||||
//create basic app
|
||||
const app = express();
|
||||
|
||||
//setting ejs as view engine
|
||||
app.set("view engine", "ejs");
|
||||
|
||||
// to connect to database
|
||||
const mongoose = require("mongoose");
|
||||
mongoose.connect("mongodb://localhost/urlShortner", {
|
||||
useNewUrlParser: true,
|
||||
useUnifiedTopology: true,
|
||||
});
|
||||
//get
|
||||
// index page with request and response parameters
|
||||
app.get("/", (req, res) => {
|
||||
res.render("index");
|
||||
});
|
||||
|
||||
//post
|
||||
app.post("/shortUrls", (req, res) => {});
|
||||
// start listening on specified port
|
||||
app.listen(process.env.PORT || 4567);
|
||||
|
||||
Reference in New Issue
Block a user