Yoonjunhyeon

vue-django 연결

Showing 41 changed files with 105 additions and 9 deletions
1 from django.urls import path, include 1 from django.urls import path, include
2 from django.conf.urls import url 2 from django.conf.urls import url
3 -from api.views import VideoFileUploadView, VideoFileList 3 +from api.views import VideoFileUploadView, VideoFileList, FileListView
4 from . import views 4 from . import views
5 from rest_framework.routers import DefaultRouter 5 from rest_framework.routers import DefaultRouter
6 +from django.views.generic import TemplateView
6 7
7 router = DefaultRouter() 8 router = DefaultRouter()
8 router.register('db/videofile', views.VideoFileViewSet) 9 router.register('db/videofile', views.VideoFileViewSet)
...@@ -12,6 +13,8 @@ urlpatterns = [ ...@@ -12,6 +13,8 @@ urlpatterns = [
12 # FBV 13 # FBV
13 path('api/upload', VideoFileUploadView.as_view(), name="file-upload"), 14 path('api/upload', VideoFileUploadView.as_view(), name="file-upload"),
14 path('api/upload/<int:pk>/', VideoFileList.as_view(), name="file-list"), 15 path('api/upload/<int:pk>/', VideoFileList.as_view(), name="file-list"),
16 + path('api/file', FileListView.as_view(), name="file"),
17 + url(r'^(?P<path>.*)$', TemplateView.as_view(template_name='index.html')),
15 # path('api/upload', views.VideoFile_Upload), 18 # path('api/upload', views.VideoFile_Upload),
16 path('', include(router.urls)), 19 path('', include(router.urls)),
17 ] 20 ]
......
...@@ -7,13 +7,16 @@ from rest_framework import viewsets ...@@ -7,13 +7,16 @@ from rest_framework import viewsets
7 import os 7 import os
8 from django.http.request import QueryDict 8 from django.http.request import QueryDict
9 from django.http import Http404 9 from django.http import Http404
10 -from django.shortcuts import get_object_or_404 10 +from django.http import JsonResponse
11 +from django.shortcuts import get_object_or_404, render
11 from api.models import Video, VideoFile 12 from api.models import Video, VideoFile
12 from api.serializers import VideoSerializer, VideoFileSerializer 13 from api.serializers import VideoSerializer, VideoFileSerializer
13 from api import file_upload_path 14 from api import file_upload_path
14 15
15 # Create your views here. 16 # Create your views here.
16 17
18 +def index(request):
19 + return render(request, template_name='index.html')
17 20
18 class VideoViewSet(viewsets.ModelViewSet): 21 class VideoViewSet(viewsets.ModelViewSet):
19 queryset = Video.objects.all() 22 queryset = Video.objects.all()
...@@ -89,3 +92,49 @@ class VideoFileList(APIView): ...@@ -89,3 +92,49 @@ class VideoFileList(APIView):
89 video = self.get_object(pk) 92 video = self.get_object(pk)
90 video.delete() 93 video.delete()
91 return Response(status=status.HTTP_204_NO_CONTENT) 94 return Response(status=status.HTTP_204_NO_CONTENT)
95 +
96 +
97 +class FileListView(APIView):
98 + def get(self, request):
99 + data = {
100 + "search": '',
101 + "limit": 10,
102 + "skip": 0,
103 + "order": "time",
104 + "fileList": [
105 + {
106 + "name": "1.png",
107 + "created": "2020-04-30",
108 + "size": 10234,
109 + "isFolder": False,
110 + "deletedDate": "",
111 + },
112 + {
113 + "name": "2.png",
114 + "created": "2020-04-30",
115 + "size": 3145,
116 + "isFolder": False,
117 + "deletedDate": "",
118 + },
119 + {
120 + "name": "3.png",
121 + "created": "2020-05-01",
122 + "size": 5653,
123 + "isFolder": False,
124 + "deletedDate": "",
125 + },
126 + ]
127 + }
128 + return Response(data)
129 + def post(self, request, format=None):
130 + data = {
131 + "isSuccess": True,
132 + "File": {
133 + "name": "test.jpg",
134 + "created": "2020-05-02",
135 + "deletedDate": "",
136 + "size": 2312,
137 + "isFolder": False
138 + }
139 + }
140 + return Response(data)
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -27,6 +27,16 @@ DEBUG = True ...@@ -27,6 +27,16 @@ DEBUG = True
27 27
28 ALLOWED_HOSTS = ['*'] 28 ALLOWED_HOSTS = ['*']
29 29
30 +
31 +# Static File DIR Settings
32 +STATIC_URL = '/static/'
33 +STATIC_ROOT = os.path.join(BASE_DIR, 'static')
34 +
35 +
36 +FRONTEND_DIR = os.path.join(os.path.abspath('../'), 'frontend')
37 +STATICFILES_DIRS = [
38 + os.path.join(FRONTEND_DIR, 'dist/'),
39 +]
30 # Application definition 40 # Application definition
31 41
32 REST_FRAMEWORK = { 42 REST_FRAMEWORK = {
...@@ -50,7 +60,7 @@ MIDDLEWARE = [ ...@@ -50,7 +60,7 @@ MIDDLEWARE = [
50 'django.middleware.security.SecurityMiddleware', 60 'django.middleware.security.SecurityMiddleware',
51 'django.contrib.sessions.middleware.SessionMiddleware', 61 'django.contrib.sessions.middleware.SessionMiddleware',
52 'django.middleware.common.CommonMiddleware', 62 'django.middleware.common.CommonMiddleware',
53 - 'django.middleware.csrf.CsrfViewMiddleware', 63 + # 'django.middleware.csrf.CsrfViewMiddleware',
54 'django.contrib.auth.middleware.AuthenticationMiddleware', 64 'django.contrib.auth.middleware.AuthenticationMiddleware',
55 'django.contrib.messages.middleware.MessageMiddleware', 65 'django.contrib.messages.middleware.MessageMiddleware',
56 'django.middleware.clickjacking.XFrameOptionsMiddleware', 66 'django.middleware.clickjacking.XFrameOptionsMiddleware',
...@@ -62,7 +72,9 @@ ROOT_URLCONF = 'backend.urls' ...@@ -62,7 +72,9 @@ ROOT_URLCONF = 'backend.urls'
62 TEMPLATES = [ 72 TEMPLATES = [
63 { 73 {
64 'BACKEND': 'django.template.backends.django.DjangoTemplates', 74 'BACKEND': 'django.template.backends.django.DjangoTemplates',
65 - 'DIRS': [], 75 + 'DIRS': [
76 + os.path.join(BASE_DIR, 'templates'),
77 + ],
66 'APP_DIRS': True, 78 'APP_DIRS': True,
67 'OPTIONS': { 79 'OPTIONS': {
68 'context_processors': [ 80 'context_processors': [
...@@ -122,12 +134,8 @@ USE_L10N = True ...@@ -122,12 +134,8 @@ USE_L10N = True
122 USE_TZ = True 134 USE_TZ = True
123 135
124 136
125 -# Static files (CSS, JavaScript, Images) 137 +# CORS settings
126 -# https://docs.djangoproject.com/en/3.0/howto/static-files/
127 -
128 -STATIC_URL = '/static/'
129 138
130 -# CORS
131 CORS_ORIGIN_ALLOW_ALL = True 139 CORS_ORIGIN_ALLOW_ALL = True
132 CORS_ALLOW_CREDENTIALS = True 140 CORS_ALLOW_CREDENTIALS = True
133 CORS_ORIGIN_WHITELIST = [ 141 CORS_ORIGIN_WHITELIST = [
......
1 asgiref==3.2.7 1 asgiref==3.2.7
2 +autopep8==1.5.2
2 Django==3.0.5 3 Django==3.0.5
3 django-cors-headers==3.2.1 4 django-cors-headers==3.2.1
5 +django-webpack-loader==0.7.0
4 djangorestframework==3.11.0 6 djangorestframework==3.11.0
7 +Pillow==7.1.2
5 pkg-resources==0.0.0 8 pkg-resources==0.0.0
9 +pycodestyle==2.5.0
6 pytz==2020.1 10 pytz==2020.1
7 sqlparse==0.3.1 11 sqlparse==0.3.1
......
1 +a:hover,a:link,a:visited{text-decoration:none}
...\ No newline at end of file ...\ No newline at end of file
This diff could not be displayed because it is too large.
No preview for this file type
1 +<!DOCTYPE html><html lang=en><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=/favicon.ico><title>Profit-Hunter</title><link href=/css/app.1dc1d4aa.css rel=preload as=style><link href=/css/chunk-vendors.abb36e73.css rel=preload as=style><link href=/js/app.a2bbd68a.js rel=preload as=script><link href=/js/chunk-vendors.c489da91.js rel=preload as=script><link href=/css/chunk-vendors.abb36e73.css rel=stylesheet><link href=/css/app.1dc1d4aa.css rel=stylesheet></head><body><noscript><strong>We're sorry but front doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script src=/js/chunk-vendors.c489da91.js></script><script src=/js/app.a2bbd68a.js></script></body></html>
...\ No newline at end of file ...\ No newline at end of file
1 +(function(t){function e(e){for(var o,i,s=e[0],c=e[1],l=e[2],f=0,d=[];f<s.length;f++)i=s[f],Object.prototype.hasOwnProperty.call(n,i)&&n[i]&&d.push(n[i][0]),n[i]=0;for(o in c)Object.prototype.hasOwnProperty.call(c,o)&&(t[o]=c[o]);u&&u(e);while(d.length)d.shift()();return r.push.apply(r,l||[]),a()}function a(){for(var t,e=0;e<r.length;e++){for(var a=r[e],o=!0,s=1;s<a.length;s++){var c=a[s];0!==n[c]&&(o=!1)}o&&(r.splice(e--,1),t=i(i.s=a[0]))}return t}var o={},n={app:0},r=[];function i(e){if(o[e])return o[e].exports;var a=o[e]={i:e,l:!1,exports:{}};return t[e].call(a.exports,a,a.exports,i),a.l=!0,a.exports}i.m=t,i.c=o,i.d=function(t,e,a){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:a})},i.r=function(t){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"===typeof t&&t&&t.__esModule)return t;var a=Object.create(null);if(i.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)i.d(a,o,function(e){return t[e]}.bind(null,o));return a},i.n=function(t){var e=t&&t.__esModule?function(){return t["default"]}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="/";var s=window["webpackJsonp"]=window["webpackJsonp"]||[],c=s.push.bind(s);s.push=e,s=s.slice();for(var l=0;l<s.length;l++)e(s[l]);var u=c;r.push([0,"chunk-vendors"]),a()})({0:function(t,e,a){t.exports=a("56d7")},"56d7":function(t,e,a){"use strict";a.r(e);a("e260"),a("e6cf"),a("cca6"),a("a79d");var o=a("2b0e"),n=function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("v-app",[a("v-app-bar",{attrs:{app:"",color:"#ffffff",elevation:"1","hide-on-scroll":""}},[a("v-icon",{staticClass:"mr-1",attrs:{size:"35",color:"grey700"}},[t._v("mdi-youtube")]),a("div",{staticStyle:{color:"#343a40","font-size":"20px","font-weight":"500"}},[t._v("Youtube Auto Tagger")]),a("v-spacer"),a("v-tooltip",{attrs:{bottom:""},scopedSlots:t._u([{key:"activator",fn:function(e){var o=e.on;return[a("v-btn",t._g({attrs:{icon:"",color:"grey700"},on:{click:function(e){t.clickInfo=!0}}},o),[a("v-icon",{attrs:{size:"30"}},[t._v("mdi-information")])],1)]}}])},[a("span",[t._v("Service Info")])])],1),a("v-dialog",{staticClass:"pa-2",attrs:{"max-width":"600"},model:{value:t.clickInfo,callback:function(e){t.clickInfo=e},expression:"clickInfo"}},[a("v-card",{staticClass:"pa-4",attrs:{elevation:"0",outlined:""}},[a("v-row",{staticClass:"mx-0 mb-8 mt-2",attrs:{justify:"center"}},[a("v-icon",{attrs:{color:"lightblue"}},[t._v("mdi-power-on")]),a("div",{staticStyle:{"text-align":"center","font-size":"22px","font-weight":"400",color:"#343a40"}},[t._v("Information of This Service")]),a("v-icon",{attrs:{color:"lightblue"}},[t._v("mdi-power-on")])],1),a("div",[t._v("Used Opensource")])],1)],1),a("v-content",[a("router-view")],1),a("v-footer",[a("v-row",{attrs:{justify:"center"}},[a("v-avatar",{staticStyle:{"border-radius":"4px"},attrs:{size:"25",tile:""}},[a("v-img",{attrs:{src:"http://khuhub.khu.ac.kr/2020-1-capstone-design1/PKH_Project1/uploads/99f7d5c73e506d2c5c0072a21f362181/logo.69342704.png"}})],1),a("a",{attrs:{href:"http://khuhub.khu.ac.kr/2020-1-capstone-design1/PKH_Project1"}},[a("div",{staticStyle:{"margin-left":"4px","font-size":"16px",color:"#5a5a5a","font-weight":"400"}},[t._v("Profit-Hunter")])])],1)],1)],1)},r=[],i={name:"App",data:function(){return{clickInfo:!1}}},s=i,c=(a("5c0b"),a("2877")),l=a("6544"),u=a.n(l),f=a("7496"),d=a("40dc"),p=a("8212"),v=a("8336"),g=a("b0af"),h=a("a75b"),y=a("169a"),m=a("553a"),b=a("132d"),x=a("adda"),w=a("0fd9"),_=a("2fa4"),k=a("3a2f"),S=Object(c["a"])(s,n,r,!1,null,null,null),V=S.exports;u()(S,{VApp:f["a"],VAppBar:d["a"],VAvatar:p["a"],VBtn:v["a"],VCard:g["a"],VContent:h["a"],VDialog:y["a"],VFooter:m["a"],VIcon:b["a"],VImg:x["a"],VRow:w["a"],VSpacer:_["a"],VTooltip:k["a"]});var C=a("8c4f"),z=a("bc3a"),j=a.n(z),P=function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("v-sheet",[a("v-layout",{attrs:{"justify-center":""}},[a("v-flex",{attrs:{xs12:"",sm8:"",md6:"",lg4:""}},[a("v-row",{staticClass:"mx-0 mt-12",attrs:{justify:"center"}},[a("div",{staticStyle:{"font-size":"34px","font-weight":"500",color:"#343a40"}},[t._v("WELCOME")])]),a("v-card",{attrs:{elevation:"0"}},[t.$vuetify.breakpoint.mdAndUp?a("v-row",{staticClass:"mx-0 mt-12",attrs:{justify:"center"}},[a("v-flex",{staticClass:"mt-1",attrs:{md7:""}},[a("div",{staticStyle:{"font-size":"20px","font-weight":"300",color:"#888"}},[t._v("This is Video auto tagging Service")]),a("div",{staticStyle:{"font-size":"20px","font-weight":"300",color:"#888"}},[t._v("Designed for Youtube Videos")]),a("div",{staticStyle:{"font-size":"20px","font-weight":"300",color:"#888"}},[t._v("It takes few minutes to analyze your Video!")])]),a("v-flex",{attrs:{md5:""}},[a("v-card",{staticClass:"ml-5",attrs:{width:"240",elevation:"0"}},[a("v-img",{attrs:{width:"240",src:"http://khuhub.khu.ac.kr/2020-1-capstone-design1/PKH_Project1/uploads/b70e4a173c2b7d5fa6ab73d48582dd6e/youtubelogoBlack.326653df.png"}})],1)],1)],1):a("v-card",{staticClass:"mt-8",attrs:{elevation:"0"}},[a("div",{staticStyle:{"font-size":"20px","font-weight":"300",color:"#888","text-align":"center"}},[t._v("This is Video auto tagging Service")]),a("div",{staticStyle:{"font-size":"20px","font-weight":"300",color:"#888","text-align":"center"}},[t._v("Designed for Youtube Videos")]),a("div",{staticStyle:{"font-size":"20px","font-weight":"300",color:"#888","text-align":"center"}},[t._v("It takes few minutes to analyze your Video!")]),a("v-img",{staticStyle:{margin:"auto","margin-top":"20px"},attrs:{width:"180",src:"http://khuhub.khu.ac.kr/2020-1-capstone-design1/PKH_Project1/uploads/b70e4a173c2b7d5fa6ab73d48582dd6e/youtubelogoBlack.326653df.png"}})],1),a("div",{staticClass:"mt-10",staticStyle:{"font-size":"24px","text-align":"center","font-weight":"400",color:"#5a5a5a"}},[t._v("How To start this service")]),a("div",{staticStyle:{"font-size":"20px","font-weight":"300",color:"#888","text-align":"center"}},[t._v("Just Upload your Video")]),a("v-row",{staticClass:"mx-0 mt-2",attrs:{justify:"center"}},[a("v-card",{staticClass:"pa-9",attrs:{"max-width":"500",outlined:"",height:"120"},on:{dragover:function(t){t.preventDefault()},dragenter:function(t){t.preventDefault()},drop:function(e){return e.preventDefault(),t.onDrop(e)}}},[a("v-btn",{staticStyle:{"text-transform":"none"},attrs:{text:"",large:"",color:"primary"},on:{click:t.clickUploadButton}},[t._v("CLICK or DRAG & DROP")]),a("input",{ref:"fileInput",staticStyle:{display:"none"},attrs:{type:"file"},on:{change:t.onFileChange}})],1)],1),a("div",{staticClass:"mt-10",staticStyle:{"font-size":"24px","text-align":"center","font-weight":"400",color:"#5a5a5a"}},[t._v("The Results of Analyzed Video")]),a("v-card",{staticClass:"pa-2 mx-5 mt-6",attrs:{outlined:"",elevation:"0","min-height":"67"}},[a("div",{staticStyle:{"margin-left":"5px","margin-top":"-18px","background-color":"#fff",width:"110px","text-align":"center","font-size":"14px",color:"#5a5a5a","font-weight":"500"}},[t._v("Generated Tags")]),a("v-chip-group",{attrs:{column:""}},t._l(t.generatedTag,(function(e,o){return a("v-chip",{key:o,attrs:{color:"secondary"}},[t._v(t._s(e))])})),1)],1),a("v-card",{staticClass:"pa-2 mx-5 mt-8",attrs:{outlined:"",elevation:"0","min-height":"67"}},[a("div",{staticStyle:{"margin-left":"5px","margin-top":"-18px","background-color":"#fff",width:"140px","text-align":"center","font-size":"14px",color:"#5a5a5a","font-weight":"500"}},[t._v("Related Youtube Link")]),t._l(t.YoutubeUrl,(function(e){return a("v-flex",{key:e},[a("div",[a("a",{attrs:{href:e}},[t._v(t._s(e))])])])}))],2),a("div",{staticClass:"mt-3",staticStyle:{"font-size":"20px","font-weight":"300",color:"#888","text-align":"center"}},[t._v("If the Video is analyzed successfully,")]),a("div",{staticClass:"mb-5",staticStyle:{"font-size":"20px","font-weight":"300",color:"#888","text-align":"center"}},[t._v("Result Show up in each of Boxes!")])],1)],1)],1)],1)},I=[],O={name:"Home",data:function(){return{videoFile:"",YoutubeUrl:[],generatedTag:[],successDialog:!1,errorDialog:!1,loading:!1}},created:function(){this.YoutubeUrl=[],this.generatedTag=[]},methods:{loadVideoInfo:function(){},uploadVideo:function(t){var e=this;console.log(t[0]);var a=new FormData;a.append("file",t[0]),this.$axios.post("/upload",a,{headers:{"Content-Type":"multipart/form-data"}}).then((function(t){e.loading=!0,console.log(t)})).catch((function(t){console.log(t.message)}))},onDrop:function(t){this.uploadVideo(t.dataTransfer.files)},clickUploadButton:function(){this.$refs.fileInput.click()},onFileChange:function(t){this.uploadVideo(t.target.files)}}},T=O,D=a("cc20"),F=a("ef9a"),B=a("0e8f"),R=a("a722"),U=a("8dd9"),A=Object(c["a"])(T,P,I,!1,null,null,null),H=A.exports;u()(A,{VBtn:v["a"],VCard:g["a"],VChip:D["a"],VChipGroup:F["a"],VFlex:B["a"],VImg:x["a"],VLayout:R["a"],VRow:w["a"],VSheet:U["a"]}),o["a"].prototype.$axios=j.a;var $="/api/";o["a"].prototype.$apiRootPath=$,j.a.defaults.baseURL=$,o["a"].use(C["a"]);var Y=[{path:"/",name:"Home",component:H}],K=new C["a"]({mode:"history",base:"/",routes:Y}),L=K,M=a("2f62");o["a"].use(M["a"]);var E=new M["a"].Store({state:{},mutations:{},actions:{},modules:{}}),G=a("f309");o["a"].use(G["a"]);var J=new G["a"]({theme:{themes:{light:{primary:"#343a40",secondary:"#506980",accent:"#505B80",error:"#FF5252",info:"#2196F3",blue:"#173f5f",lightblue:"#72b1e4",success:"#2779bd",warning:"#12283a",grey300:"#eceeef",grey500:"#aaaaaa",grey700:"#5a5a5a",grey900:"#212529"},dark:{primary:"#343a40",secondary:"#506980",accent:"#505B80",error:"#FF5252",info:"#2196F3",blue:"#173f5f",lightblue:"#72b1e4",success:"#2779bd",warning:"#12283a",grey300:"#eceeef",grey500:"#aaaaaa",grey700:"#5a5a5a",grey900:"#212529"}}}});a("d5e8"),a("5363");o["a"].config.productionTip=!1,new o["a"]({router:L,store:E,vuetify:J,render:function(t){return t(V)}}).$mount("#app")},"5c0b":function(t,e,a){"use strict";var o=a("7694"),n=a.n(o);n.a},7694:function(t,e,a){}});
2 +//# sourceMappingURL=app.a2bbd68a.js.map
...\ No newline at end of file ...\ No newline at end of file
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
1 +{% load static %}
2 +<!doctype html>
3 +<html lang="en">
4 +
5 +<head>
6 + <meta charset=utf-8>
7 + <meta http-equiv=X-UA-Compatible content="IE=edge">
8 + <meta name=viewport content="width=device-width,initial-scale=1">
9 + <link rel=icon href="{% static 'favicon.ico' %}">
10 + <title>front</title>
11 + <link href="{% static '/css/app.1dc1d4aa.css' %}" rel=preload as=style>
12 + <link href="{% static '/css/chunk-vendors.abb36e73.css' %}" rel=preload as=style>
13 + <link href="{% static '/js/app.a2bbd68a.js' %}" rel=preload as=script>
14 + <link href="{% static '/js/chunk-vendors.c489da91.js' %}" rel=preload as=script>
15 + <link href="{% static '/css/chunk-vendors.abb36e73.css' %}" rel=stylesheet>
16 + <link href="{% static '/css/app.1dc1d4aa.css' %}" rel=stylesheet>
17 +</head>
18 +
19 +<body>
20 + <noscript><strong>We're sorry but front doesn't work properly without JavaScript enabled. Please enable it to
21 + continue.</strong></noscript>
22 + <div id=app>
23 + </div>
24 + <script src="{% static '/js/chunk-vendors.c489da91.js' %}"></script>
25 + <script src="{% static '/js/app.a2bbd68a.js' %}"></script>
26 +</body>
27 +
28 +</html>
...\ No newline at end of file ...\ No newline at end of file