Ubuntu

remove khuloud directory

1 -<!DOCTYPE html>
2 -<html lang="en">
3 -<head>
4 - <meta charset="UTF-8">
5 - <title>{% block title %}{% endblock%}</title>
6 -</head>
7 -<body>
8 - {% block content %}{% endblock %}
9 -</body>
10 -</html>
...\ No newline at end of file ...\ No newline at end of file
1 -<h1>
2 - hi!
3 -</h1>
...\ No newline at end of file ...\ No newline at end of file
1 -<!DOCTYPE html>
2 -<html lang="en">
3 -<head>
4 - <meta charset="utf-8">
5 - <meta http-equiv="X-UA-Compatible" content="IE=edge">
6 -
7 - <title>KHUropBox</title>
8 -
9 - <script src="/static/js/app.js"></script>
10 - <script src="/static/js/aws-sdk.min.js"></script>
11 -
12 - <link href="/static/css/app.css" rel="stylesheet">
13 - <link href="/static/css/common.css" rel="stylesheet">
14 - <link href="/static/css/override.css" rel="stylesheet">
15 - <link href="/static/css/layout.css" rel="stylesheet">
16 - <link href="/static/css/filebrowser.css" rel="stylesheet">
17 - <link href="/static/css/font-awesome.min.css" rel="stylesheet">
18 -
19 -
20 -</head>
21 -<body>
22 - <div id="wrapper">
23 - <div id="page-content-wrapper">
24 -
25 - <div id="header">
26 - <div id="logo">
27 - <a href="/"></a>
28 - </div>
29 - </div>
30 -
31 - <div id="content">
32 - {% block content %}
33 - {% endblock %}
34 - </div>
35 - </div>
36 - </div>
37 -
38 -</body>
...\ No newline at end of file ...\ No newline at end of file
1 -{% extends 'layout.html' %}
2 -
3 -{% block content %}
4 -
5 - <div class="col-md-8 col-md-offset-2">
6 - <div class="panel panel-default">
7 - <div class="panel-heading">로그인</div>
8 - <div class="panel-body">
9 - <form class="form-horizontal" role="form" method="POST" action="/login/">
10 -
11 - {% csrf_token %}
12 - <div class="form-group">
13 - <div class="col-md-12">
14 - <label for="userid">아이디</label>
15 - <input id="userid" type="userid" class="form-control" name="username" required autofocus>
16 - </div>
17 - </div>
18 -
19 - <div class="form-group">
20 - <div class="col-md-12">
21 - <label for="password">비밀번호</label>
22 - <input id="password" type="password" class="form-control" name="password" required>
23 - </div>
24 - </div>
25 -
26 - <div class="form-group">
27 - <div class="col-md-12">
28 - <button type="submit" class="btn btn-success">
29 - 로그인
30 - </button>
31 - <button class="btn btn-success" onclick="location.href='/register/';">
32 - 회원가입
33 - </button>
34 - </div>
35 - </div>
36 -
37 - <div class="form-group">
38 - <div class="col-md-12 text-center">
39 - <h5>{{ message }}</h5>
40 - </div>
41 - </div>
42 -
43 - </form>
44 - </div>
45 - </div>
46 - </div>
47 -
48 -{% endblock %}
...\ No newline at end of file ...\ No newline at end of file
1 -{% extends 'layout.html' %}
2 -
3 -{% block content %}
4 -
5 - <div class="col-md-8 col-md-offset-2">
6 - <div class="panel panel-default">
7 - <div class="panel-heading">
8 - {{ request.user.username }} 님 안녕하세요.
9 - <button type="submit" class="btn right" onclick="location.href='/logout/';">로그아웃</button>
10 - </div>
11 - </div>
12 - </div>
13 -{% endblock %}
1 -{% extends 'layout.html' %}
2 -
3 -{% block content %}
4 -
5 - <div class="col-md-8 col-md-offset-2">
6 - <div class="panel panel-default">
7 -
8 - <div class="panel-body">
9 - <form class="form-horizontal" role="form" method="POST" action="/register/">
10 - {% csrf_token %}
11 -
12 - <div class="form-group">
13 - <div class="col-md-12">
14 - <label for="username"><span style="color:green;">아이디</span></label>
15 - <input id="username" type="text" class="form-control" name="username" required autofocus>
16 - </div>
17 - </div>
18 -
19 - <div class="form-group">
20 - <div class="col-md-12">
21 - <label for="email"><span style="color:green;">이메일</span><h6 style="display:inline;"> - 비밀번호 분실시 사용됩니다.</h6></label>
22 - <input id="email" type="email" class="form-control" name="email" required>
23 - </div>
24 - </div>
25 -
26 - <div class="form-group">
27 - <div class="col-md-12">
28 - <label for="password"><span style="color:green;">비밀번호</span><h6 style="display:inline;"> - 비밀번호는 8자리 이상으로 설정되어야 합니다.</h6></label>
29 - <input id="password" type="password" class="form-control" name="password" required>
30 - </div>
31 - </div>
32 -
33 - <div class="form-group">
34 -
35 - <div class="col-md-12">
36 -
37 - <label for="first_name"><span style="color:green;"></span></label>
38 -
39 - <input id="first_name" type="first_name" class="form-control" name="first_name" required>
40 -
41 - </div>
42 -
43 - </div>
44 -
45 - <div class="form-group">
46 -
47 - <div class="col-md-12">
48 -
49 - <label for="last_name"><span style="color:green;">이름</span></label>
50 -
51 - <input id="last_name" type="last_name" class="form-control" name="last_name" required>
52 -
53 - </div>
54 -
55 - </div>
56 -
57 - <div class="form-group">
58 - <div class="col-md-12">
59 - <button type="submit" class="btn btn-success">회원가입</button>
60 - </div>
61 - </div>
62 -
63 - <div class="form-group">
64 - <div class="col-md-12 text-center">
65 - <h6>{{ message }}</h6>
66 - </div>
67 - </div>
68 -
69 - </form>
70 - </div>
71 - </div>
72 - </div>
73 -
74 -{% endblock %}
1 -from django.contrib.auth.models import User
2 -from django.contrib.auth import authenticate
3 -from django.shortcuts import render, redirect
4 -from django.core.exceptions import PermissionDenied
5 -from khuloud import settings
6 -from khuloud import cognito
7 -from django.views.decorators.csrf import csrf_exempt
8 -import hashlib
9 -
10 -import django
11 -
12 -
13 -def main(request):
14 - if request.user.is_authenticated:
15 - return render(request, "main.html")
16 - else:
17 - return render(request, "login.html")
18 -
19 -def login(request):
20 - if request.method == "POST":
21 - if not all(i in request.POST for i in ('username', 'password')):
22 - return render(request, "login.html", {
23 - "message": "please enter id and passowrd"
24 - })
25 -
26 - un = request.POST['username']
27 - pw = request.POST['password']
28 -
29 - user = authenticate(username=un, password=pw)
30 -
31 - if user is not None:
32 - auth = django.contrib.auth.login(request, user)
33 -
34 - hashcode = hashlib.md5(request.POST['password'].encode('utf-8')).hexdigest()
35 -
36 - cog = cognito.Cognito()
37 - cog.sign_in_admin(username=un, password=hashcode)
38 -
39 - return redirect('/main')
40 - else:
41 - return render(request, "login.html", {
42 - "message": "check id and password"
43 - })
44 - else:
45 - return render(request, "login.html")
46 -
47 -def logout(request):
48 - if request.user.is_authenticated:
49 - django.contrib.auth.logout(request)
50 - return redirect("/main")
51 -def register(request):
52 - Cog = cognito.Cognito()
53 - if request.method == "POST":
54 - require_keys = ('username', 'password', 'first_name', 'last_name', 'email')
55 - if all(i in request.POST for i in require_keys):
56 - if User.objects.filter(username=request.POST['username']).count():
57 - return render(request, 'register.html', {
58 - "message": 'alreay exist id!'
59 - })
60 - if User.objects.filter(email=request.POST['email']).count():
61 - return render(request, 'register.html', {
62 - "message": 'already exist email'
63 - })
64 -
65 - userobj = User.objects.create_user(
66 - username=request.POST['username'],
67 - password=request.POST['password'],
68 - first_name=request.POST['first_name'],
69 - last_name=request.POST['last_name'],
70 - email=request.POST['email']
71 - )
72 -
73 - hashcode = hashlib.md5(request.POST['password'].encode('utf-8')).hexdigest()
74 -
75 - Cog.sign_up(
76 - username=request.POST['username'],
77 - password=hashcode,
78 - UserAttributes=[
79 - {
80 - 'Name' : 'email',
81 - 'Value' : request.POST['email'],
82 - },
83 - {
84 - 'Name' : 'family_name',
85 - 'Value': request.POST['first_name'],
86 - },
87 - {
88 - 'Name' : 'given_name',
89 - 'Value': request.POST['last_name'],
90 - },
91 - ])
92 -
93 - Cog.confirm_sign_up(username=request.POST['username']);
94 -
95 - return redirect('/main')
96 - else:
97 - return render(request, 'register.html', {
98 - "message": 'erroe!'
99 - })
100 - else:
101 - return render(request, 'register.html')
1 -"""khuloud URL Configuration
2 -
3 -The `urlpatterns` list routes URLs to views. For more information please see:
4 - https://docs.djangoproject.com/en/1.11/topics/http/urls/
5 -Examples:
6 -Function views
7 - 1. Add an import: from my_app import views
8 - 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
9 -Class-based views
10 - 1. Add an import: from other_app.views import Home
11 - 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
12 -Including another URLconf
13 - 1. Import the include() function: from django.conf.urls import url, include
14 - 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
15 -"""
16 -import blog.views
17 -from django.contrib import admin
18 -from django.conf import settings
19 -from django.conf.urls.static import static
20 -from django.conf.urls import include, url
21 -urlpatterns = [
22 - url(r'^admin/', admin.site.urls),
23 - url('main/',blog.views.main, name='main'),
24 - url(r'^login/', blog.views.login, name='login'),
25 - url(r'^logout/', blog.views.logout, name='logout'),
26 - url(r'^register/', blog.views.register, name='register'),
27 -]+ static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)