second form

This commit is contained in:
revvie 2018-03-13 17:29:56 +02:00
parent b218769fac
commit b0c4f991ba
4 changed files with 34 additions and 4 deletions

View File

@ -9,6 +9,10 @@ const path = require('path')
const express = require('express')
const bodyParser = require('body-parser')
const chalk = require('chalk')
const pg = require('pg')
// initialize an pg instance
const pgConnection = "postgres://postgres:postgres@localhost:5432/books"
// initialize an express instance
const server = express()
@ -29,6 +33,7 @@ if (process.env.NODE_ENV !== 'production') {
server.use(bodyParser.json())
server.use(bodyParser.urlencoded({ extended: true }))
// server routes
server.get('/', (req, res, next) => {
res.render('index')
})
@ -50,6 +55,10 @@ server.post('/search', (req, res, next) => {
res.status(200).redirect('/result')
})
server.post('/login', (req, res, next) => {
console.log(req.body)
})
// server.use('/', (req, res, next) => {
// console.log('hello')
// res.send('<h1>Hello</h1>')

View File

@ -14,8 +14,14 @@
<h1>Deem</h1>
<nav>
<ul>
<li><a href="/">Start</a></li>
<li><a href="/search">Search</a></li>
<li><a href="/result">Result</a></li>
<li>
<a href="/">Start</a>
</li>
<li>
<a href="/search">Search</a>
</li>
<li>
<a href="/result">Result</a>
</li>
</ul>
</nav>
</nav>

View File

@ -4,4 +4,5 @@
<p>To the most legit website in the world. Besides rating books you can also buy pretty good drugs.</p>
<% include login %>
<% include footer %>

View File

@ -0,0 +1,14 @@
<!-- <% include header %> -->
<form class="pure-form" action="/login" method="POST">
<p>Login:</p>
<input type="text" name="Username" placeholder="Enter username" autofocus required />
<input type="password" name="Password" placeholder="Enter password" autofocus required />
<input type="submit" value="Login">
<p>Create account</p>
<input type="text" name="Desired username" placeholder="Enter username" autofocus required />
<input type="text" name="Email" placeholder="Enter email" autofocus required />
<input type="submit" value="Create">
</form>
<!-- <% include footer %> -->