-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathindex.js
More file actions
44 lines (40 loc) · 1.2 KB
/
Copy pathindex.js
File metadata and controls
44 lines (40 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
global.express = require('express');
global.app = express();
global.bodyParser = require('body-parser');
global.sorgu = require('./sorgu.js').sorgu;
global.ejs = require('ejs');
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
extended: true
}));
app.set('view engine', 'ejs');
app.use(express.static('views'));
///////////////////////// GET - POST /////////////////////////
app.get('/', (req, res) => {
res.render('index');
});
app.post('/check', async (req, res) => {
let {
username
} = req.body;
if (!username) return res.send({
error: true,
message: 'Lütfen bir kullanıcı adı giriniz.'
});
if (username.length < 3) return res.send({
error: true,
message: 'Kullanıcı adı 3 karakterden az olamaz.'
});
let check = await sorgu(username);
if (!check.status) return res.send({
error: true,
message: 'Bir hata oluştu. Lütfen daha sonra tekrar deneyiniz.'
});
res.render('profile', {
profile: check
});
});
///////////////////////// GET - POST /////////////////////////
app.listen(80, () => {
console.log('Web site açıldı. Port: 80')
});