Yoonjunhyeon

backend 파일 업로드 완료

Showing 132 changed files with 516 additions and 1343 deletions
1 +import os
2 +from django.conf.global_settings import FILE_UPLOAD_MAX_MEMORY_SIZE
3 +import datetime
4 +import uuid
5 +
6 +# 각 media 파일에 대한 URL Prefix
7 +MEDIA_URL = '/media/' # 항상 / 로 끝나도록 설정
8 +# MEDIA_URL = 'http://static.myservice.com/media/' 다른 서버로 media 파일 복사시
9 +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
10 +
11 +MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
12 +
13 +# 파일 업로드 사이즈 100M ( 100 * 1024 * 1024 )
14 +#FILE_UPLOAD_MAX_MEMORY_SIZE = 104857600
15 +
16 +# 실제 파일을 저장할 경로 및 파일 명 생성
17 +# 폴더는 일별로 생성됨
18 +def file_upload_path( filename):
19 + ext = filename.split('.')[-1]
20 + d = datetime.datetime.now()
21 + filepath = d.strftime('%Y\\%m\\%d')
22 + suffix = d.strftime("%Y%m%d%H%M%S")
23 + filename = "%s_%s.%s"%(uuid.uuid4().hex, suffix, ext)
24 + return os.path.join( MEDIA_ROOT , filepath, filename)
25 +
26 +# DB 필드에서 호출
27 +def file_upload_path_for_db( intance, filename):
28 + return file_upload_path(filename)
...\ No newline at end of file ...\ No newline at end of file
1 -# Generated by Django 3.0.5 on 2020-04-20 07:34 1 +# Generated by Django 3.0.5 on 2020-05-02 12:19
2 2
3 +import api
3 from django.db import migrations, models 4 from django.db import migrations, models
4 -import jsonfield.fields
5 5
6 6
7 class Migration(migrations.Migration): 7 class Migration(migrations.Migration):
...@@ -16,9 +16,18 @@ class Migration(migrations.Migration): ...@@ -16,9 +16,18 @@ class Migration(migrations.Migration):
16 name='Video', 16 name='Video',
17 fields=[ 17 fields=[
18 ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 18 ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
19 - ('videourl', models.URLField(max_length=400)), 19 + ('videourl', models.CharField(blank=True, max_length=1000)),
20 ('title', models.CharField(max_length=200)), 20 ('title', models.CharField(max_length=200)),
21 - ('tags', jsonfield.fields.JSONField()), 21 + ('tags', models.CharField(max_length=500)),
22 + ],
23 + ),
24 + migrations.CreateModel(
25 + name='VideoFile',
26 + fields=[
27 + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
28 + ('file_save_name', models.FileField(upload_to=api.file_upload_path_for_db)),
29 + ('file_origin_name', models.CharField(max_length=100)),
30 + ('file_path', models.CharField(max_length=100)),
22 ], 31 ],
23 ), 32 ),
24 ] 33 ]
......
1 from django.db import models 1 from django.db import models
2 -from jsonfield import JSONField 2 +from api import file_upload_path_for_db
3 +# Create your models here.
3 4
4 5
5 -# Create your models here.
6 class Video(models.Model): 6 class Video(models.Model):
7 - videourl = models.CharField(max_length=1000, blank=True) 7 + videourl = models.CharField(max_length=1000, blank=True)
8 - title = models.CharField(max_length=200) 8 + title = models.CharField(max_length=200)
9 - tags = models.CharField(max_length=500) 9 + tags = models.CharField(max_length=500)
10 - 10 +
11 -class Tags(models.Model):
12 - tag = models.CharField(max_length=200)
13 11
14 class VideoFile(models.Model): 12 class VideoFile(models.Model):
15 - video = models.FileField(upload_to='uploads/%Y/%m/%d/%h/%m/%s', max_length=100), 13 + file_save_name = models.FileField(upload_to=file_upload_path_for_db, blank=False, null=False)
14 + # 파일의 원래 이름
15 + file_origin_name = models.CharField(max_length=100)
16 + # 파일 저장 경로
17 + file_path = models.CharField(max_length=100)
18 +
19 + def __str__(self):
20 + return self.file.name
......
1 -from .models import Video, Tags
2 from rest_framework import serializers 1 from rest_framework import serializers
2 +from api.models import Video, VideoFile
3 +
3 4
4 class VideoSerializer(serializers.ModelSerializer): 5 class VideoSerializer(serializers.ModelSerializer):
5 6
...@@ -7,11 +8,9 @@ class VideoSerializer(serializers.ModelSerializer): ...@@ -7,11 +8,9 @@ class VideoSerializer(serializers.ModelSerializer):
7 model = Video 8 model = Video
8 fields = '__all__' 9 fields = '__all__'
9 10
10 -class TagSerializer(serializers.ModelSerializer): 11 +
12 +class VideoFileSerializer(serializers.ModelSerializer):
11 13
12 class Meta: 14 class Meta:
13 - model = Tags 15 + model = VideoFile
14 fields = '__all__' 16 fields = '__all__'
15 -#dict화 방법
16 -#serializer = VideoSerializer(Video.objects.all(), many=True)
17 -#serializer.data
...\ No newline at end of file ...\ No newline at end of file
......
1 from django.urls import path, include 1 from django.urls import path, include
2 +from django.conf.urls import url
3 +from api.views import VideoFileUploadView, VideoFileList
2 from . import views 4 from . import views
3 from rest_framework.routers import DefaultRouter 5 from rest_framework.routers import DefaultRouter
4 6
5 router = DefaultRouter() 7 router = DefaultRouter()
6 -router.register('db/tags', views.TagViewSet) 8 +router.register('db/videofile', views.VideoFileViewSet)
7 router.register('db/video', views.VideoViewSet) 9 router.register('db/video', views.VideoViewSet)
8 10
9 urlpatterns = [ 11 urlpatterns = [
10 # FBV 12 # FBV
11 - path('api/video', views.Video_list),
12 - path('api/loadtag', views.Tag_list),
13 - path('',include(router.urls)),
14 - # path('cbv/post/<int:pk>/',views.post_detail),
15 -]
...\ No newline at end of file ...\ No newline at end of file
13 + 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', views.VideoFile_Upload),
16 + path('', include(router.urls)),
17 +]
......
1 +from rest_framework import status
2 +from rest_framework.views import APIView
3 +from rest_framework.response import Response
4 +from rest_framework.parsers import MultiPartParser, FormParser
5 +from rest_framework.response import Response
6 +from rest_framework import viewsets
7 +import os
8 +from django.http.request import QueryDict
9 +from django.http import Http404
10 +from django.shortcuts import get_object_or_404
11 +from api.models import Video, VideoFile
12 +from api.serializers import VideoSerializer, VideoFileSerializer
13 +from api import file_upload_path
14 +
15 +# Create your views here.
16 +
17 +
18 +class VideoViewSet(viewsets.ModelViewSet):
19 + queryset = Video.objects.all()
20 + serializer_class = VideoSerializer
21 +
22 +
23 +class VideoFileViewSet(viewsets.ModelViewSet):
24 + queryset = VideoFile.objects.all()
25 + serializer_class = VideoFileSerializer
26 +
27 +class VideoFileUploadView(APIView):
28 + parser_classes = (MultiPartParser, FormParser)
29 +
30 + def get(self, request, format=None):
31 + videoFiles = VideoFile.objects.all()
32 + serializer = VideoFileSerializer(videoFiles, many=True)
33 + return Response(serializer.data)
34 +
35 + def post(self, req, *args, **kwargs):
36 + # 요청된 데이터를 꺼냄( QueryDict)
37 + new_data = req.data.dict()
38 +
39 + # 요청된 파일 객체
40 + print(req.data)
41 + file_name = req.data['file']
42 +
43 + # 저장될 파일의 풀path를 생성
44 + new_file_full_name = file_upload_path(file_name.name)
45 +
46 + # 새롭게 생성된 파일의 경로
47 + file_path = '\\'.join(new_file_full_name.split('\\')[0:-1])
48 +
49 + new_data['file_path'] = file_path
50 + new_data['file_origin_name'] = req.data['file'].name
51 + new_data['file_save_name'] = req.data['file']
52 +
53 + new_query_dict = QueryDict('', mutable=True)
54 + new_query_dict.update(new_data)
55 +
56 + file_serializer = VideoFileSerializer(data = new_query_dict)
57 + if file_serializer.is_valid():
58 + file_serializer.save()
59 + print(file_serializer.data)
60 +
61 + return Response(True, status=status.HTTP_201_CREATED)
62 + else:
63 + return Response(file_serializer.errors, status=status.HTTP_400_BAD_REQUEST)
64 +
65 +
66 +class VideoFileList(APIView):
67 +
68 + def get_object(self, pk):
69 + try:
70 + return VideoFile.objects.get(pk=pk)
71 + except VideoFile.DoesNotExist:
72 + raise Http404
73 +
74 + def get(self, request, pk, format=None):
75 + video = self.get_object(pk)
76 + serializer = VideoFileSerializer(video)
77 + return Response(serializer.data)
78 +
79 + def put(self, request, pk, format=None):
80 + video = self.get_object(pk)
81 + serializer = VideoFileSerializer(video, data=request.data)
82 + if serializer.is_valid():
83 + serializer.save()
84 + return Response(serializer.data)
85 + return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
86 +
87 + def delete(self, request, pk, format=None):
88 + video = self.get_object(pk)
89 + video.delete()
90 + return Response(status=status.HTTP_204_NO_CONTENT)
1 -var createError = require('http-errors');
2 -var express = require('express');
3 -var path = require('path');
4 -var cookieParser = require('cookie-parser');
5 -var logger = require('morgan');
6 -var history = require('connect-history-api-fallback');
7 -var cors = require('cors');
8 -var app = express();
9 -var mongoDB = require('./lib/db_info');
10 -
11 -app.use(logger('dev'));
12 -app.use(express.json());
13 -app.use(express.urlencoded({ extended: false }));
14 -app.use(cookieParser());
15 -
16 -if (process.env.NODE_ENV !== 'production') app.use(cors());
17 -app.use('/api', require('./routes/api'));
18 -app.use(history());
19 -app.use(express.static(path.join(__dirname, '../frontend', 'dist')));
20 -// catch 404 and forward to error handler
21 -app.use(function (req, res, next) {
22 - next(createError(404));
23 -});
24 -
25 -// error handler
26 -app.use(function (err, req, res, next) {
27 - // set locals, only providing error in development
28 - res.locals.message = err.message;
29 - res.locals.error = req.app.get('env') === 'development' ? err : {};
30 -
31 - // render the error page
32 - res.status(err.status || 500);
33 - res.send({ msg: err.message });
34 - console.error(err.message);
35 -});
36 -
37 -module.exports = app;
38 -
39 -const mongoose = require('mongoose');
40 -
41 -mongoose.connect(
42 - mongoDB.db,
43 - { useNewUrlParser: true, useUnifiedTopology: true, useFindAndModify: true },
44 - (err) => {
45 - if (err) return console.error(err);
46 - console.log('mongoose connected');
47 - }
48 -);
1 """ 1 """
2 -ASGI config for djangoBackend project. 2 +ASGI config for backend project.
3 3
4 It exposes the ASGI callable as a module-level variable named ``application``. 4 It exposes the ASGI callable as a module-level variable named ``application``.
5 5
...@@ -11,6 +11,6 @@ import os ...@@ -11,6 +11,6 @@ import os
11 11
12 from django.core.asgi import get_asgi_application 12 from django.core.asgi import get_asgi_application
13 13
14 -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'djangoBackend.settings') 14 +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'backend.settings')
15 15
16 application = get_asgi_application() 16 application = get_asgi_application()
......
1 """ 1 """
2 -Django settings for djangoBackend project. 2 +Django settings for backend project.
3 3
4 Generated by 'django-admin startproject' using Django 3.0.5. 4 Generated by 'django-admin startproject' using Django 3.0.5.
5 5
...@@ -20,16 +20,20 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) ...@@ -20,16 +20,20 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
20 # See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/ 20 # See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
21 21
22 # SECURITY WARNING: keep the secret key used in production secret! 22 # SECURITY WARNING: keep the secret key used in production secret!
23 -SECRET_KEY = '$gr0=rm@72sybv94!q4%+#x20q$#27df9g8z%3$%528uf_*dn0' 23 +SECRET_KEY = '7e^4!u6019jww&=-!mu%r$hz6jy#=i+i9@9m_44+ga^#%7#e0l'
24 24
25 # SECURITY WARNING: don't run with debug turned on in production! 25 # SECURITY WARNING: don't run with debug turned on in production!
26 DEBUG = True 26 DEBUG = True
27 27
28 -ALLOWED_HOSTS = [] 28 +ALLOWED_HOSTS = ['*']
29 -
30 29
31 # Application definition 30 # Application definition
32 31
32 +REST_FRAMEWORK = {
33 + 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
34 + 'PAGE_SIZE': 10
35 +}
36 +
33 INSTALLED_APPS = [ 37 INSTALLED_APPS = [
34 'django.contrib.admin', 38 'django.contrib.admin',
35 'django.contrib.auth', 39 'django.contrib.auth',
...@@ -38,9 +42,8 @@ INSTALLED_APPS = [ ...@@ -38,9 +42,8 @@ INSTALLED_APPS = [
38 'django.contrib.messages', 42 'django.contrib.messages',
39 'django.contrib.staticfiles', 43 'django.contrib.staticfiles',
40 'rest_framework', 44 'rest_framework',
41 - 'rest_framework_swagger',
42 'corsheaders', 45 'corsheaders',
43 - 'api', 46 + 'api'
44 ] 47 ]
45 48
46 MIDDLEWARE = [ 49 MIDDLEWARE = [
...@@ -54,7 +57,7 @@ MIDDLEWARE = [ ...@@ -54,7 +57,7 @@ MIDDLEWARE = [
54 'corsheaders.middleware.CorsMiddleware', 57 'corsheaders.middleware.CorsMiddleware',
55 ] 58 ]
56 59
57 -ROOT_URLCONF = 'djangoBackend.urls' 60 +ROOT_URLCONF = 'backend.urls'
58 61
59 TEMPLATES = [ 62 TEMPLATES = [
60 { 63 {
...@@ -72,7 +75,7 @@ TEMPLATES = [ ...@@ -72,7 +75,7 @@ TEMPLATES = [
72 }, 75 },
73 ] 76 ]
74 77
75 -WSGI_APPLICATION = 'djangoBackend.wsgi.application' 78 +WSGI_APPLICATION = 'backend.wsgi.application'
76 79
77 80
78 # Database 81 # Database
...@@ -124,11 +127,15 @@ USE_TZ = True ...@@ -124,11 +127,15 @@ USE_TZ = True
124 127
125 STATIC_URL = '/static/' 128 STATIC_URL = '/static/'
126 129
127 -##CORS 130 +# CORS
128 -CORS_ORIGIN_ALLOW_ALL=True 131 +CORS_ORIGIN_ALLOW_ALL = True
129 CORS_ALLOW_CREDENTIALS = True 132 CORS_ALLOW_CREDENTIALS = True
133 +CORS_ORIGIN_WHITELIST = [
134 + "http://127.0.0.1:12233",
135 + "http://localhost:8080",
136 + "http://127.0.0.1:9000"
137 +]
130 CORS_URLS_REGEX = r'^/api/.*$' 138 CORS_URLS_REGEX = r'^/api/.*$'
131 -
132 CORS_ALLOW_METHODS = ( 139 CORS_ALLOW_METHODS = (
133 'DELETE', 140 'DELETE',
134 'GET', 141 'GET',
...@@ -148,4 +155,4 @@ CORS_ALLOW_HEADERS = ( ...@@ -148,4 +155,4 @@ CORS_ALLOW_HEADERS = (
148 'user-agent', 155 'user-agent',
149 'x-csrftoken', 156 'x-csrftoken',
150 'x-requested-with', 157 'x-requested-with',
151 -)
...\ No newline at end of file ...\ No newline at end of file
158 +)
......
1 -"""djangoBackend URL Configuration 1 +"""backend URL Configuration
2 2
3 The `urlpatterns` list routes URLs to views. For more information please see: 3 The `urlpatterns` list routes URLs to views. For more information please see:
4 https://docs.djangoproject.com/en/3.0/topics/http/urls/ 4 https://docs.djangoproject.com/en/3.0/topics/http/urls/
...@@ -16,11 +16,10 @@ Including another URLconf ...@@ -16,11 +16,10 @@ Including another URLconf
16 from django.contrib import admin 16 from django.contrib import admin
17 from django.urls import path 17 from django.urls import path
18 from django.conf.urls import url, include 18 from django.conf.urls import url, include
19 -from rest_framework import routers 19 +from django.conf import settings
20 -from rest_framework_swagger.views import get_swagger_view 20 +from django.conf.urls.static import static
21 21
22 urlpatterns = [ 22 urlpatterns = [
23 - url(r'^admin/', admin.site.urls),
24 - url(r'^api/doc', get_swagger_view(title='Rest API Document')),
25 path('', include('api.urls')), 23 path('', include('api.urls')),
26 -] 24 + path('admin/', admin.site.urls),
25 +]
...\ No newline at end of file ...\ No newline at end of file
......
1 """ 1 """
2 -WSGI config for djangoBackend project. 2 +WSGI config for backend project.
3 3
4 It exposes the WSGI callable as a module-level variable named ``application``. 4 It exposes the WSGI callable as a module-level variable named ``application``.
5 5
...@@ -11,6 +11,6 @@ import os ...@@ -11,6 +11,6 @@ import os
11 11
12 from django.core.wsgi import get_wsgi_application 12 from django.core.wsgi import get_wsgi_application
13 13
14 -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'djangoBackend.settings') 14 +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'backend.settings')
15 15
16 application = get_wsgi_application() 16 application = get_wsgi_application()
......
1 -#!/usr/bin/env node
2 -
3 -/**
4 - * Module dependencies.
5 - */
6 -
7 -var app = require('../app');
8 -var debug = require('debug')('backend:server');
9 -var http = require('http');
10 -
11 -/**
12 - * Get port from environment and store in Express.
13 - */
14 -
15 -var port = normalizePort(process.env.PORT || '3000');
16 -app.set('port', port);
17 -
18 -/**
19 - * Create HTTP server.
20 - */
21 -
22 -var server = http.createServer(app);
23 -
24 -/**
25 - * Listen on provided port, on all network interfaces.
26 - */
27 -
28 -server.listen(port);
29 -server.on('error', onError);
30 -server.on('listening', onListening);
31 -
32 -/**
33 - * Normalize a port into a number, string, or false.
34 - */
35 -
36 -function normalizePort(val) {
37 - var port = parseInt(val, 10);
38 -
39 - if (isNaN(port)) {
40 - // named pipe
41 - return val;
42 - }
43 -
44 - if (port >= 0) {
45 - // port number
46 - return port;
47 - }
48 -
49 - return false;
50 -}
51 -
52 -/**
53 - * Event listener for HTTP server "error" event.
54 - */
55 -
56 -function onError(error) {
57 - if (error.syscall !== 'listen') {
58 - throw error;
59 - }
60 -
61 - var bind = typeof port === 'string'
62 - ? 'Pipe ' + port
63 - : 'Port ' + port;
64 -
65 - // handle specific listen errors with friendly messages
66 - switch (error.code) {
67 - case 'EACCES':
68 - console.error(bind + ' requires elevated privileges');
69 - process.exit(1);
70 - break;
71 - case 'EADDRINUSE':
72 - console.error(bind + ' is already in use');
73 - process.exit(1);
74 - break;
75 - default:
76 - throw error;
77 - }
78 -}
79 -
80 -/**
81 - * Event listener for HTTP server "listening" event.
82 - */
83 -
84 -function onListening() {
85 - var addr = server.address();
86 - var bind = typeof addr === 'string'
87 - ? 'pipe ' + addr
88 - : 'port ' + addr.port;
89 - debug('Listening on ' + bind);
90 -}
1 # This file must be used with "source bin/activate" *from bash* 1 # This file must be used with "source bin/activate" *from bash*
2 # you cannot run it directly 2 # you cannot run it directly
3 3
4 -
5 -if [ "${BASH_SOURCE-}" = "$0" ]; then
6 - echo "You must source this script: \$ source $0" >&2
7 - exit 33
8 -fi
9 -
10 deactivate () { 4 deactivate () {
11 - unset -f pydoc >/dev/null 2>&1
12 -
13 # reset old environment variables 5 # reset old environment variables
14 - # ! [ -z ${VAR+_} ] returns true if VAR is declared at all 6 + if [ -n "${_OLD_VIRTUAL_PATH:-}" ] ; then
15 - if ! [ -z "${_OLD_VIRTUAL_PATH:+_}" ] ; then 7 + PATH="${_OLD_VIRTUAL_PATH:-}"
16 - PATH="$_OLD_VIRTUAL_PATH"
17 export PATH 8 export PATH
18 unset _OLD_VIRTUAL_PATH 9 unset _OLD_VIRTUAL_PATH
19 fi 10 fi
20 - if ! [ -z "${_OLD_VIRTUAL_PYTHONHOME+_}" ] ; then 11 + if [ -n "${_OLD_VIRTUAL_PYTHONHOME:-}" ] ; then
21 - PYTHONHOME="$_OLD_VIRTUAL_PYTHONHOME" 12 + PYTHONHOME="${_OLD_VIRTUAL_PYTHONHOME:-}"
22 export PYTHONHOME 13 export PYTHONHOME
23 unset _OLD_VIRTUAL_PYTHONHOME 14 unset _OLD_VIRTUAL_PYTHONHOME
24 fi 15 fi
...@@ -26,18 +17,18 @@ deactivate () { ...@@ -26,18 +17,18 @@ deactivate () {
26 # This should detect bash and zsh, which have a hash command that must 17 # This should detect bash and zsh, which have a hash command that must
27 # be called to get it to forget past commands. Without forgetting 18 # be called to get it to forget past commands. Without forgetting
28 # past commands the $PATH changes we made may not be respected 19 # past commands the $PATH changes we made may not be respected
29 - if [ -n "${BASH-}" ] || [ -n "${ZSH_VERSION-}" ] ; then 20 + if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
30 - hash -r 2>/dev/null 21 + hash -r
31 fi 22 fi
32 23
33 - if ! [ -z "${_OLD_VIRTUAL_PS1+_}" ] ; then 24 + if [ -n "${_OLD_VIRTUAL_PS1:-}" ] ; then
34 - PS1="$_OLD_VIRTUAL_PS1" 25 + PS1="${_OLD_VIRTUAL_PS1:-}"
35 export PS1 26 export PS1
36 unset _OLD_VIRTUAL_PS1 27 unset _OLD_VIRTUAL_PS1
37 fi 28 fi
38 29
39 unset VIRTUAL_ENV 30 unset VIRTUAL_ENV
40 - if [ ! "${1-}" = "nondestructive" ] ; then 31 + if [ ! "$1" = "nondestructive" ] ; then
41 # Self destruct! 32 # Self destruct!
42 unset -f deactivate 33 unset -f deactivate
43 fi 34 fi
...@@ -46,7 +37,7 @@ deactivate () { ...@@ -46,7 +37,7 @@ deactivate () {
46 # unset irrelevant variables 37 # unset irrelevant variables
47 deactivate nondestructive 38 deactivate nondestructive
48 39
49 -VIRTUAL_ENV='/mnt/c/_/PKH_Project1/web/env' 40 +VIRTUAL_ENV="/home/jun/documents/Univ/PKH_Project1/web/backend/env"
50 export VIRTUAL_ENV 41 export VIRTUAL_ENV
51 42
52 _OLD_VIRTUAL_PATH="$PATH" 43 _OLD_VIRTUAL_PATH="$PATH"
...@@ -54,31 +45,32 @@ PATH="$VIRTUAL_ENV/bin:$PATH" ...@@ -54,31 +45,32 @@ PATH="$VIRTUAL_ENV/bin:$PATH"
54 export PATH 45 export PATH
55 46
56 # unset PYTHONHOME if set 47 # unset PYTHONHOME if set
57 -if ! [ -z "${PYTHONHOME+_}" ] ; then 48 +# this will fail if PYTHONHOME is set to the empty string (which is bad anyway)
58 - _OLD_VIRTUAL_PYTHONHOME="$PYTHONHOME" 49 +# could use `if (set -u; : $PYTHONHOME) ;` in bash
50 +if [ -n "${PYTHONHOME:-}" ] ; then
51 + _OLD_VIRTUAL_PYTHONHOME="${PYTHONHOME:-}"
59 unset PYTHONHOME 52 unset PYTHONHOME
60 fi 53 fi
61 54
62 -if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT-}" ] ; then 55 +if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then
63 - _OLD_VIRTUAL_PS1="${PS1-}" 56 + _OLD_VIRTUAL_PS1="${PS1:-}"
64 - if [ "x" != x ] ; then 57 + if [ "x(env) " != x ] ; then
65 - PS1="${PS1-}" 58 + PS1="(env) ${PS1:-}"
59 + else
60 + if [ "`basename \"$VIRTUAL_ENV\"`" = "__" ] ; then
61 + # special case for Aspen magic directories
62 + # see http://www.zetadev.com/software/aspen/
63 + PS1="[`basename \`dirname \"$VIRTUAL_ENV\"\``] $PS1"
66 else 64 else
67 - PS1="(`basename \"$VIRTUAL_ENV\"`) ${PS1-}" 65 + PS1="(`basename \"$VIRTUAL_ENV\"`)$PS1"
66 + fi
68 fi 67 fi
69 export PS1 68 export PS1
70 fi 69 fi
71 70
72 -# Make sure to unalias pydoc if it's already there
73 -alias pydoc 2>/dev/null >/dev/null && unalias pydoc || true
74 -
75 -pydoc () {
76 - python -m pydoc "$@"
77 -}
78 -
79 # This should detect bash and zsh, which have a hash command that must 71 # This should detect bash and zsh, which have a hash command that must
80 # be called to get it to forget past commands. Without forgetting 72 # be called to get it to forget past commands. Without forgetting
81 # past commands the $PATH changes we made may not be respected 73 # past commands the $PATH changes we made may not be respected
82 -if [ -n "${BASH-}" ] || [ -n "${ZSH_VERSION-}" ] ; then 74 +if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
83 - hash -r 2>/dev/null 75 + hash -r
84 fi 76 fi
......
1 +# This file must be used with "source bin/activate.csh" *from csh*.
2 +# You cannot run it directly.
3 +# Created by Davide Di Blasi <davidedb@gmail.com>.
4 +# Ported to Python 3.3 venv by Andrew Svetlov <andrew.svetlov@gmail.com>
5 +
6 +alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; test "\!:*" != "nondestructive" && unalias deactivate'
7 +
8 +# Unset irrelevant variables.
9 +deactivate nondestructive
10 +
11 +setenv VIRTUAL_ENV "/home/jun/documents/Univ/PKH_Project1/web/backend/env"
12 +
13 +set _OLD_VIRTUAL_PATH="$PATH"
14 +setenv PATH "$VIRTUAL_ENV/bin:$PATH"
15 +
16 +
17 +set _OLD_VIRTUAL_PROMPT="$prompt"
18 +
19 +if (! "$?VIRTUAL_ENV_DISABLE_PROMPT") then
20 + if ("env" != "") then
21 + set env_name = "env"
22 + else
23 + if (`basename "VIRTUAL_ENV"` == "__") then
24 + # special case for Aspen magic directories
25 + # see http://www.zetadev.com/software/aspen/
26 + set env_name = `basename \`dirname "$VIRTUAL_ENV"\``
27 + else
28 + set env_name = `basename "$VIRTUAL_ENV"`
29 + endif
30 + endif
31 + set prompt = "[$env_name] $prompt"
32 + unset env_name
33 +endif
34 +
35 +alias pydoc python -m pydoc
36 +
37 +rehash
1 +# This file must be used with ". bin/activate.fish" *from fish* (http://fishshell.org)
2 +# you cannot run it directly
3 +
4 +function deactivate -d "Exit virtualenv and return to normal shell environment"
5 + # reset old environment variables
6 + if test -n "$_OLD_VIRTUAL_PATH"
7 + set -gx PATH $_OLD_VIRTUAL_PATH
8 + set -e _OLD_VIRTUAL_PATH
9 + end
10 + if test -n "$_OLD_VIRTUAL_PYTHONHOME"
11 + set -gx PYTHONHOME $_OLD_VIRTUAL_PYTHONHOME
12 + set -e _OLD_VIRTUAL_PYTHONHOME
13 + end
14 +
15 + if test -n "$_OLD_FISH_PROMPT_OVERRIDE"
16 + functions -e fish_prompt
17 + set -e _OLD_FISH_PROMPT_OVERRIDE
18 + functions -c _old_fish_prompt fish_prompt
19 + functions -e _old_fish_prompt
20 + end
21 +
22 + set -e VIRTUAL_ENV
23 + if test "$argv[1]" != "nondestructive"
24 + # Self destruct!
25 + functions -e deactivate
26 + end
27 +end
28 +
29 +# unset irrelevant variables
30 +deactivate nondestructive
31 +
32 +set -gx VIRTUAL_ENV "/home/jun/documents/Univ/PKH_Project1/web/backend/env"
33 +
34 +set -gx _OLD_VIRTUAL_PATH $PATH
35 +set -gx PATH "$VIRTUAL_ENV/bin" $PATH
36 +
37 +# unset PYTHONHOME if set
38 +if set -q PYTHONHOME
39 + set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME
40 + set -e PYTHONHOME
41 +end
42 +
43 +if test -z "$VIRTUAL_ENV_DISABLE_PROMPT"
44 + # fish uses a function instead of an env var to generate the prompt.
45 +
46 + # save the current fish_prompt function as the function _old_fish_prompt
47 + functions -c fish_prompt _old_fish_prompt
48 +
49 + # with the original prompt function renamed, we can override with our own.
50 + function fish_prompt
51 + # Save the return status of the last command
52 + set -l old_status $status
53 +
54 + # Prompt override?
55 + if test -n "(env) "
56 + printf "%s%s" "(env) " (set_color normal)
57 + else
58 + # ...Otherwise, prepend env
59 + set -l _checkbase (basename "$VIRTUAL_ENV")
60 + if test $_checkbase = "__"
61 + # special case for Aspen magic directories
62 + # see http://www.zetadev.com/software/aspen/
63 + printf "%s[%s]%s " (set_color -b blue white) (basename (dirname "$VIRTUAL_ENV")) (set_color normal)
64 + else
65 + printf "%s(%s)%s" (set_color -b blue white) (basename "$VIRTUAL_ENV") (set_color normal)
66 + end
67 + end
68 +
69 + # Restore the return status of the previous command.
70 + echo "exit $old_status" | .
71 + _old_fish_prompt
72 + end
73 +
74 + set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV"
75 +end
1 -#!/mnt/c/_/PKH_Project1/web/env/bin/python 1 +#!/home/jun/documents/Univ/PKH_Project1/web/backend/env/bin/python3
2 +
2 # -*- coding: utf-8 -*- 3 # -*- coding: utf-8 -*-
3 import re 4 import re
4 import sys 5 import sys
5 -from chardet.cli.chardetect import main 6 +
7 +from autopep8 import main
8 +
6 if __name__ == '__main__': 9 if __name__ == '__main__':
7 - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) 10 + sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
8 sys.exit(main()) 11 sys.exit(main())
......
1 -#!/mnt/c/_/PKH_Project1/web/env/bin/python 1 +#!/home/jun/documents/Univ/PKH_Project1/web/backend/env/bin/python
2 +
2 # -*- coding: utf-8 -*- 3 # -*- coding: utf-8 -*-
3 import re 4 import re
4 import sys 5 import sys
6 +
5 from django.core.management import execute_from_command_line 7 from django.core.management import execute_from_command_line
8 +
6 if __name__ == '__main__': 9 if __name__ == '__main__':
7 - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) 10 + sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
8 sys.exit(execute_from_command_line()) 11 sys.exit(execute_from_command_line())
......
1 -#!/mnt/c/_/PKH_Project1/web/env/bin/python 1 +#!/home/jun/documents/Univ/PKH_Project1/web/backend/env/bin/python
2 from django.core import management 2 from django.core import management
3 3
4 if __name__ == "__main__": 4 if __name__ == "__main__":
......
1 -#!/mnt/c/_/PKH_Project1/web/env/bin/python 1 +#!/home/jun/documents/Univ/PKH_Project1/web/backend/env/bin/python
2 +
2 # -*- coding: utf-8 -*- 3 # -*- coding: utf-8 -*-
3 import re 4 import re
4 import sys 5 import sys
6 +
5 from setuptools.command.easy_install import main 7 from setuptools.command.easy_install import main
8 +
6 if __name__ == '__main__': 9 if __name__ == '__main__':
7 - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) 10 + sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
8 sys.exit(main()) 11 sys.exit(main())
......
1 -#!/mnt/c/_/PKH_Project1/web/env/bin/python 1 +#!/home/jun/documents/Univ/PKH_Project1/web/backend/env/bin/python
2 +
2 # -*- coding: utf-8 -*- 3 # -*- coding: utf-8 -*-
3 import re 4 import re
4 import sys 5 import sys
6 +
5 from setuptools.command.easy_install import main 7 from setuptools.command.easy_install import main
8 +
6 if __name__ == '__main__': 9 if __name__ == '__main__':
7 - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) 10 + sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
8 sys.exit(main()) 11 sys.exit(main())
......
1 -#!/mnt/c/_/PKH_Project1/web/env/bin/python 1 +#!/home/jun/documents/Univ/PKH_Project1/web/backend/env/bin/python
2 +
2 # -*- coding: utf-8 -*- 3 # -*- coding: utf-8 -*-
3 import re 4 import re
4 import sys 5 import sys
5 -from setuptools.command.easy_install import main 6 +
7 +from pip import main
8 +
6 if __name__ == '__main__': 9 if __name__ == '__main__':
7 - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) 10 + sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
8 sys.exit(main()) 11 sys.exit(main())
......
1 -#!/mnt/c/_/PKH_Project1/web/env/bin/python 1 +#!/home/jun/documents/Univ/PKH_Project1/web/backend/env/bin/python
2 +
2 # -*- coding: utf-8 -*- 3 # -*- coding: utf-8 -*-
3 import re 4 import re
4 import sys 5 import sys
5 -from pip._internal.cli.main import main 6 +
7 +from pip import main
8 +
6 if __name__ == '__main__': 9 if __name__ == '__main__':
7 - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) 10 + sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
8 sys.exit(main()) 11 sys.exit(main())
......
1 -#!/mnt/c/_/PKH_Project1/web/env/bin/python 1 +#!/home/jun/documents/Univ/PKH_Project1/web/backend/env/bin/python
2 +
2 # -*- coding: utf-8 -*- 3 # -*- coding: utf-8 -*-
3 import re 4 import re
4 import sys 5 import sys
5 -from pip._internal.cli.main import main 6 +
7 +from pip import main
8 +
6 if __name__ == '__main__': 9 if __name__ == '__main__':
7 - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) 10 + sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
8 sys.exit(main()) 11 sys.exit(main())
......
1 -#!/mnt/c/_/PKH_Project1/web/env/bin/python 1 +#!/home/jun/documents/Univ/PKH_Project1/web/backend/env/bin/python3
2 +
2 # -*- coding: utf-8 -*- 3 # -*- coding: utf-8 -*-
3 import re 4 import re
4 import sys 5 import sys
5 -from pip._internal.cli.main import main 6 +
7 +from pycodestyle import _main
8 +
6 if __name__ == '__main__': 9 if __name__ == '__main__':
7 - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) 10 + sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
8 - sys.exit(main()) 11 + sys.exit(_main())
......
1 +/usr/bin/python
...\ No newline at end of file ...\ No newline at end of file
1 +python
...\ No newline at end of file ...\ No newline at end of file
1 -#!/mnt/c/_/PKH_Project1/web/env/bin/python 1 +#!/home/jun/documents/Univ/PKH_Project1/web/backend/env/bin/python
2 +
2 # -*- coding: utf-8 -*- 3 # -*- coding: utf-8 -*-
3 import re 4 import re
4 import sys 5 import sys
6 +
5 from sqlparse.__main__ import main 7 from sqlparse.__main__ import main
8 +
6 if __name__ == '__main__': 9 if __name__ == '__main__':
7 - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) 10 + sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
8 sys.exit(main()) 11 sys.exit(main())
......
1 +lib
...\ No newline at end of file ...\ No newline at end of file
1 +home = /usr/bin
2 +include-system-site-packages = false
3 +version = 3.6.9
1 #!/bin/bash 1 #!/bin/bash
2 source ./env/bin/activate 2 source ./env/bin/activate
3 +python manage.py migrate
3 python manage.py runserver 4 python manage.py runserver
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -5,7 +5,7 @@ import sys ...@@ -5,7 +5,7 @@ import sys
5 5
6 6
7 def main(): 7 def main():
8 - os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'djangoBackend.settings') 8 + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'backend.settings')
9 try: 9 try:
10 from django.core.management import execute_from_command_line 10 from django.core.management import execute_from_command_line
11 except ImportError as exc: 11 except ImportError as exc:
......
1 -const mongoose = require('mongoose')
2 -mongoose.set('useCreateIndex', true)
3 -
4 -const Tag = new mongoose.Schema({
5 - tag: [],
6 -})
7 -
8 -const tag = mongoose.model('tag', Tag)
9 -
10 -module.exports = tag
...\ No newline at end of file ...\ No newline at end of file
1 -const mongoose = require('mongoose')
2 -mongoose.set('useCreateIndex', true)
3 -
4 -const postSchema = new mongoose.Schema({
5 - tag: [],
6 - videoUrl: { type: String, default: '',},
7 - title: { type: String, default: '' },
8 -})
9 -
10 -const Post = mongoose.model('post', postSchema)
11 -
12 -module.exports = Post
...\ No newline at end of file ...\ No newline at end of file
1 -{
2 - "name": "backend",
3 - "version": "0.0.0",
4 - "private": true,
5 - "scripts": {
6 - "start": "node ./bin/www"
7 - },
8 - "dependencies": {
9 - "connect-history-api-fallback": "^1.6.0",
10 - "cookie-parser": "^1.4.5",
11 - "cors": "^2.8.5",
12 - "debug": "~2.6.9",
13 - "express": "~4.16.1",
14 - "http-errors": "~1.6.3",
15 - "moment": "^2.24.0",
16 - "mongoose": "^5.9.7",
17 - "morgan": "~1.9.1",
18 - "multer": "^1.4.2",
19 - "pug": "2.0.0-beta11"
20 - }
21 -}
1 +asgiref==3.2.7
2 +Django==3.0.5
3 +django-cors-headers==3.2.1
4 +djangorestframework==3.11.0
5 +pkg-resources==0.0.0
6 +pytz==2020.1
7 +sqlparse==0.3.1
1 -var express = require('express');
2 -var createError = require('http-errors');
3 -var router = express.Router();
4 -const post = require('../../../model/video');
5 -const tags = require('../../../model/tagList');
6 -
7 -router.get('/list', (req, res, next) => {
8 - let { tags, skip } = req.query;
9 - let joinedTag;
10 - console.log(tags);
11 - if (tags) joinedTag = tags.join('|');
12 - else {
13 - joinedTag = '';
14 - }
15 - let regexsearch = { tag: { $regex: joinedTag, $options: 'si' } };
16 - skip = parseInt(skip);
17 - post
18 - .find(regexsearch)
19 - .sort({ _id: -1 })
20 - .limit(10)
21 - .skip(skip)
22 - .then((rs) => {
23 - res.send({ success: true, d: rs });
24 - })
25 - .catch((e) => {
26 - console.log(e);
27 - res.send({ success: false, msg: e.message });
28 - });
29 -});
30 -
31 -router.get('/tag', (req, res, next) => {
32 - tags
33 - .find()
34 - .then((rs) => {
35 - var temp = [];
36 - rs.forEach((element) => {
37 - element.tag.forEach((element) => {
38 - temp.push(element);
39 - });
40 - });
41 - var uniqArray = Array.from(new Set(temp));
42 - res.send({ success: true, d: uniqArray });
43 - })
44 - .catch((e) => {
45 - console.log(e);
46 - res.send({ success: false, msg: e.message });
47 - });
48 -});
49 -
50 -router.delete('/:_id', (req, res, next) => {
51 - const _id = req.params._id;
52 - post
53 - .findOne({ _id })
54 - .then((r) => {
55 - console.log(r);
56 - return post.deleteOne({ _id });
57 - })
58 - .then((r) => {
59 - res.send({ success: true, d: r });
60 - })
61 - .catch((e) => {
62 - console.log(e);
63 - res.send({ success: false, msg: e.message });
64 - });
65 -});
66 -
67 -router.all('*', function (req, res, next) {
68 - next(new Error('Wrong Url!'));
69 -});
70 -
71 -module.exports = router;
1 -var createError = require('http-errors');
2 -var express = require('express');
3 -var router = express.Router();
4 -
5 -router.use('/home', require('./home'));
6 -router.use('/upload', require('./upload'));
7 -
8 -router.all('*', function (req, res, next) {
9 - next(createError(404, 'This page is not exisit'));
10 -});
11 -
12 -module.exports = router;
1 -var express = require('express');
2 -var createError = require('http-errors');
3 -var router = express.Router();
4 -const post = require('../../../model/video');
5 -const tags = require('../../../model/tagList');
6 -const multer = require('multer');
7 -var moment = require('moment');
8 -var fs = require('fs');
9 -// event post
10 -router.post(
11 - '/video',
12 - multer({ dest: 'videos/' }).single('bin'),
13 - (req, res, next) => {
14 - console.log(req.file);
15 -
16 - fs.rename(
17 - `../../../videos/${req.file.filename}`,
18 - `../../../videos/${req.file.originalname}`,
19 - (r) => {
20 - console.log(r);
21 - }
22 - );
23 - var atc = {
24 - videoUrl: req.file.location,
25 - title: req.body.title,
26 - tag: req.body.tag,
27 - };
28 - // post.create(atc)
29 - // .then( r => {
30 - // res.send({ success: true, d: r, token: req.token })
31 - // })
32 - // .catch((err) => {
33 - // console.log(err);
34 - // res.send({ success: false, msg: err.message })
35 - // });
36 - }
37 -);
38 -router.post('/post', (req, res, next) => {
39 - console.log(req.body);
40 - var atc = {
41 - title: req.body.title,
42 - tag: req.body.tag,
43 - };
44 - tags
45 - .create({ tag: req.body.tag })
46 - .then(() => {
47 - return post.create(atc);
48 - })
49 - .then((r) => {
50 - res.send({ success: true, d: r, token: req.token });
51 - })
52 - .catch((err) => {
53 - console.log(err);
54 - res.send({ success: false, msg: err.message });
55 - });
56 -});
57 -
58 -router.all('*', function (req, res, next) {
59 - next(createError(404, 'This page is not exisit'));
60 -});
61 -
62 -module.exports = router;
1 #!/bin/bash 1 #!/bin/bash
2 +python manage.py migrate
2 python manage.py runserver 0.0.0.0:8000 3 python manage.py runserver 0.0.0.0:8000
...\ No newline at end of file ...\ No newline at end of file
......
This diff is collapsed. Click to expand it.
1 -class ListCreateAPIView(mixins.ListModelMixin,
2 - mixins.CreateModelMixin,
3 - GenericAPIView):
4 -
5 - def get(self, request, *args, **kwargs):
6 - return self.list(request, *args, **kwargs)
7 -
8 - def post(self, request, *args, **kwargs):
9 - return self.create(request, *args, **kwargs)
...\ No newline at end of file ...\ No newline at end of file
1 -# Generated by Django 3.0.5 on 2020-04-20 15:42
2 -
3 -import django.contrib.postgres.fields
4 -from django.db import migrations, models
5 -
6 -
7 -class Migration(migrations.Migration):
8 -
9 - dependencies = [
10 - ('api', '0001_initial'),
11 - ]
12 -
13 - operations = [
14 - migrations.CreateModel(
15 - name='Tags',
16 - fields=[
17 - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
18 - ('tag', models.CharField(max_length=200)),
19 - ],
20 - ),
21 - migrations.AlterField(
22 - model_name='video',
23 - name='videourl',
24 - field=models.CharField(max_length=1000),
25 - ),
26 - ]
1 -# Generated by Django 3.0.5 on 2020-04-20 15:47
2 -
3 -from django.db import migrations
4 -import jsonfield.fields
5 -
6 -
7 -class Migration(migrations.Migration):
8 -
9 - dependencies = [
10 - ('api', '0002_auto_20200420_1542'),
11 - ]
12 -
13 - operations = [
14 - migrations.AlterField(
15 - model_name='video',
16 - name='tags',
17 - field=jsonfield.fields.JSONField(),
18 - ),
19 - ]
1 -# Generated by Django 3.0.5 on 2020-04-20 16:08
2 -
3 -from django.db import migrations, models
4 -
5 -
6 -class Migration(migrations.Migration):
7 -
8 - dependencies = [
9 - ('api', '0003_auto_20200420_1547'),
10 - ]
11 -
12 - operations = [
13 - migrations.AlterField(
14 - model_name='video',
15 - name='tags',
16 - field=models.CharField(max_length=500),
17 - ),
18 - migrations.AlterField(
19 - model_name='video',
20 - name='videourl',
21 - field=models.CharField(blank=True, max_length=1000),
22 - ),
23 - ]
1 -from rest_framework.response import Response
2 -from rest_framework.views import APIView
3 -from .models import Video, Tags
4 -from .serializer import VideoSerializer, TagSerializer
5 -from rest_framework.decorators import api_view
6 -from django.shortcuts import get_object_or_404
7 -from rest_framework import generics
8 -from rest_framework import mixins
9 -from rest_framework import viewsets
10 -
11 -# Create your views here.
12 -class VideoViewSet(viewsets.ModelViewSet):
13 - queryset = Video.objects.all()
14 - serializer_class = VideoSerializer
15 -
16 -class TagViewSet(viewsets.ModelViewSet):
17 - queryset = Tags.objects.order_by('tag')
18 - serializer_class = TagSerializer
19 -
20 -
21 -# FBV 예제
22 -@api_view(['GET','POST'])
23 -def Video_list(request):
24 - if request.method == 'GET':
25 - qs = Video.objects.all()
26 - serializer = VideoSerializer(qs, many=True)
27 - return Response(serializer.data)
28 - else:
29 - for i in request.data['tag']:
30 - convertTag = {'tag':i}
31 - tagSerial = TagSerializer(data=convertTag)
32 -
33 - if tagSerial.is_valid():
34 - tagSerial.save()
35 - else:
36 - print(tagSerial.errors)
37 -
38 - request.data['tags'] = ','.join(request.data['tag'])
39 - serializer = VideoSerializer(data=request.data)
40 -
41 - if serializer.is_valid():
42 - serializer.save()
43 - return Response(serializer.data, status=201)
44 -
45 - print(serializer.errors)
46 - return Response(serializer.errors, status=400)
47 -
48 -@api_view(['GET'])
49 -def Tag_list(request):
50 - if request.method == 'GET':
51 - qs = Tags.objects.order_by('tag')
52 - serializer = TagSerializer(qs, many=True)
53 - returnData = serializer.data
54 - return Response(serializer.data)
55 -
56 -
57 - # 삭제, 수정은 나중에 넣음.
58 - # elif request.method == 'PUT':
59 - # serializer = VideoSerializer(video, data=request.data)
60 - # if serializer.is_valid():
61 - # serializer.save()
62 - # return Response(serializer.data)
63 - # return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
64 - # else:
65 - # video.delete()
66 - # return Response(status=status.HTTP_204_NO_CONTENT)
67 -
68 -# @api_view(['GET','PUT','DELETE'])
69 -# def post_detail(request, pk):
70 -# post = get_object_or_404(Post, pk=pk)
71 -# if request.method == 'GET':
72 -# serializer = PostSerializer(post)
73 -# return Response(serializer.data)
74 -# elif request.method == 'PUT':
75 -# serializer = PostSerializer(post, data=reqeust.data)
76 -# if serializer.is_valid():
77 -# serializer.save()
78 -# return Response(serializer.data)
79 -# return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
80 -# else:
81 -# post.delete()
82 -# return Response(status=status.HTTP_204_NO_CONTENT)
83 -
84 -
85 -
86 -
87 -
88 -# Mixin example
89 -
90 -# class TagListMixins(mixins.ListModelMixin, mixins.CreateModelMixin,generics.GenericAPIView):
91 -# def get(self, request, *args, **kwargs):
92 -# return self.list(request)
93 -
94 -# def post(self, request, *args, **kwargs):
95 -# return self.create(request)
96 -
97 -
98 -# class PostDetailMixins(mixins.RetrieveModelMixin, mixins.UpdateModelMixin, mixins.DestroyModelMixin, generics.GenericAPIView):
99 -# queryset = Video.objects.all()
100 -# serializer_class = VideoSerializer
101 -
102 -# def get(self, request, *args, **kwargs):
103 -# return self.retrieve(request, *args, **kwargs)
104 -
105 -# def put(self, request, *args, **kwargs):
106 -# return self.update(request, *args, **kwargs)
107 -
108 -# def delete(self, request, *args, **kwargs):
109 -# return self.delete(request, *args, **kwargs)
110 -
111 -
1 -# This file must be used with "source bin/activate.csh" *from csh*.
2 -# You cannot run it directly.
3 -# Created by Davide Di Blasi <davidedb@gmail.com>.
4 -
5 -set newline='\
6 -'
7 -
8 -alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH:q" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT:q" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; test "\!:*" != "nondestructive" && unalias deactivate && unalias pydoc'
9 -
10 -# Unset irrelevant variables.
11 -deactivate nondestructive
12 -
13 -setenv VIRTUAL_ENV '/mnt/c/_/PKH_Project1/web/env'
14 -
15 -set _OLD_VIRTUAL_PATH="$PATH:q"
16 -setenv PATH "$VIRTUAL_ENV:q/bin:$PATH:q"
17 -
18 -
19 -
20 -if ('' != "") then
21 - set env_name = ''
22 -else
23 - set env_name = '('"$VIRTUAL_ENV:t:q"') '
24 -endif
25 -
26 -if ( $?VIRTUAL_ENV_DISABLE_PROMPT ) then
27 - if ( $VIRTUAL_ENV_DISABLE_PROMPT == "" ) then
28 - set do_prompt = "1"
29 - else
30 - set do_prompt = "0"
31 - endif
32 -else
33 - set do_prompt = "1"
34 -endif
35 -
36 -if ( $do_prompt == "1" ) then
37 - # Could be in a non-interactive environment,
38 - # in which case, $prompt is undefined and we wouldn't
39 - # care about the prompt anyway.
40 - if ( $?prompt ) then
41 - set _OLD_VIRTUAL_PROMPT="$prompt:q"
42 - if ( "$prompt:q" =~ *"$newline:q"* ) then
43 - :
44 - else
45 - set prompt = "$env_name:q$prompt:q"
46 - endif
47 - endif
48 -endif
49 -
50 -unset env_name
51 -unset do_prompt
52 -
53 -alias pydoc python -m pydoc
54 -
55 -rehash
1 -# This file must be used using `source bin/activate.fish` *within a running fish ( http://fishshell.com ) session*.
2 -# Do not run it directly.
3 -
4 -function _bashify_path -d "Converts a fish path to something bash can recognize"
5 - set fishy_path $argv
6 - set bashy_path $fishy_path[1]
7 - for path_part in $fishy_path[2..-1]
8 - set bashy_path "$bashy_path:$path_part"
9 - end
10 - echo $bashy_path
11 -end
12 -
13 -function _fishify_path -d "Converts a bash path to something fish can recognize"
14 - echo $argv | tr ':' '\n'
15 -end
16 -
17 -function deactivate -d 'Exit virtualenv mode and return to the normal environment.'
18 - # reset old environment variables
19 - if test -n "$_OLD_VIRTUAL_PATH"
20 - # https://github.com/fish-shell/fish-shell/issues/436 altered PATH handling
21 - if test (echo $FISH_VERSION | head -c 1) -lt 3
22 - set -gx PATH (_fishify_path "$_OLD_VIRTUAL_PATH")
23 - else
24 - set -gx PATH "$_OLD_VIRTUAL_PATH"
25 - end
26 - set -e _OLD_VIRTUAL_PATH
27 - end
28 -
29 - if test -n "$_OLD_VIRTUAL_PYTHONHOME"
30 - set -gx PYTHONHOME "$_OLD_VIRTUAL_PYTHONHOME"
31 - set -e _OLD_VIRTUAL_PYTHONHOME
32 - end
33 -
34 - if test -n "$_OLD_FISH_PROMPT_OVERRIDE"
35 - and functions -q _old_fish_prompt
36 - # Set an empty local `$fish_function_path` to allow the removal of `fish_prompt` using `functions -e`.
37 - set -l fish_function_path
38 -
39 - # Erase virtualenv's `fish_prompt` and restore the original.
40 - functions -e fish_prompt
41 - functions -c _old_fish_prompt fish_prompt
42 - functions -e _old_fish_prompt
43 - set -e _OLD_FISH_PROMPT_OVERRIDE
44 - end
45 -
46 - set -e VIRTUAL_ENV
47 -
48 - if test "$argv[1]" != 'nondestructive'
49 - # Self-destruct!
50 - functions -e pydoc
51 - functions -e deactivate
52 - functions -e _bashify_path
53 - functions -e _fishify_path
54 - end
55 -end
56 -
57 -# Unset irrelevant variables.
58 -deactivate nondestructive
59 -
60 -set -gx VIRTUAL_ENV '/mnt/c/_/PKH_Project1/web/env'
61 -
62 -# https://github.com/fish-shell/fish-shell/issues/436 altered PATH handling
63 -if test (echo $FISH_VERSION | head -c 1) -lt 3
64 - set -gx _OLD_VIRTUAL_PATH (_bashify_path $PATH)
65 -else
66 - set -gx _OLD_VIRTUAL_PATH "$PATH"
67 -end
68 -set -gx PATH "$VIRTUAL_ENV"'/bin' $PATH
69 -
70 -# Unset `$PYTHONHOME` if set.
71 -if set -q PYTHONHOME
72 - set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME
73 - set -e PYTHONHOME
74 -end
75 -
76 -function pydoc
77 - python -m pydoc $argv
78 -end
79 -
80 -if test -z "$VIRTUAL_ENV_DISABLE_PROMPT"
81 - # Copy the current `fish_prompt` function as `_old_fish_prompt`.
82 - functions -c fish_prompt _old_fish_prompt
83 -
84 - function fish_prompt
85 - # Run the user's prompt first; it might depend on (pipe)status.
86 - set -l prompt (_old_fish_prompt)
87 -
88 - # Prompt override provided?
89 - # If not, just prepend the environment name.
90 - if test -n ''
91 - printf '%s%s' '' (set_color normal)
92 - else
93 - printf '%s(%s) ' (set_color normal) (basename "$VIRTUAL_ENV")
94 - end
95 -
96 - string join -- \n $prompt # handle multi-line prompts
97 - end
98 -
99 - set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV"
100 -end
1 -$script:THIS_PATH = $myinvocation.mycommand.path
2 -$script:BASE_DIR = Split-Path (Resolve-Path "$THIS_PATH/..") -Parent
3 -
4 -function global:deactivate([switch] $NonDestructive) {
5 - if (Test-Path variable:_OLD_VIRTUAL_PATH) {
6 - $env:PATH = $variable:_OLD_VIRTUAL_PATH
7 - Remove-Variable "_OLD_VIRTUAL_PATH" -Scope global
8 - }
9 -
10 - if (Test-Path function:_old_virtual_prompt) {
11 - $function:prompt = $function:_old_virtual_prompt
12 - Remove-Item function:\_old_virtual_prompt
13 - }
14 -
15 - if ($env:VIRTUAL_ENV) {
16 - Remove-Item env:VIRTUAL_ENV -ErrorAction SilentlyContinue
17 - }
18 -
19 - if (!$NonDestructive) {
20 - # Self destruct!
21 - Remove-Item function:deactivate
22 - Remove-Item function:pydoc
23 - }
24 -}
25 -
26 -function global:pydoc {
27 - python -m pydoc $args
28 -}
29 -
30 -# unset irrelevant variables
31 -deactivate -nondestructive
32 -
33 -$VIRTUAL_ENV = $BASE_DIR
34 -$env:VIRTUAL_ENV = $VIRTUAL_ENV
35 -
36 -New-Variable -Scope global -Name _OLD_VIRTUAL_PATH -Value $env:PATH
37 -
38 -$env:PATH = "$env:VIRTUAL_ENV/bin:" + $env:PATH
39 -if (!$env:VIRTUAL_ENV_DISABLE_PROMPT) {
40 - function global:_old_virtual_prompt {
41 - ""
42 - }
43 - $function:_old_virtual_prompt = $function:prompt
44 -
45 - if ("" -ne "") {
46 - function global:prompt {
47 - # Add the custom prefix to the existing prompt
48 - $previous_prompt_value = & $function:_old_virtual_prompt
49 - ("" + $previous_prompt_value)
50 - }
51 - }
52 - else {
53 - function global:prompt {
54 - # Add a prefix to the current prompt, but don't discard it.
55 - $previous_prompt_value = & $function:_old_virtual_prompt
56 - $new_prompt_value = "($( Split-Path $env:VIRTUAL_ENV -Leaf )) "
57 - ($new_prompt_value + $previous_prompt_value)
58 - }
59 - }
60 -}
1 -"""Xonsh activate script for virtualenv"""
2 -from xonsh.tools import get_sep as _get_sep
3 -
4 -def _deactivate(args):
5 - if "pydoc" in aliases:
6 - del aliases["pydoc"]
7 -
8 - if ${...}.get("_OLD_VIRTUAL_PATH", ""):
9 - $PATH = $_OLD_VIRTUAL_PATH
10 - del $_OLD_VIRTUAL_PATH
11 -
12 - if ${...}.get("_OLD_VIRTUAL_PYTHONHOME", ""):
13 - $PYTHONHOME = $_OLD_VIRTUAL_PYTHONHOME
14 - del $_OLD_VIRTUAL_PYTHONHOME
15 -
16 - if "VIRTUAL_ENV" in ${...}:
17 - del $VIRTUAL_ENV
18 -
19 - if "VIRTUAL_ENV_PROMPT" in ${...}:
20 - del $VIRTUAL_ENV_PROMPT
21 -
22 - if "nondestructive" not in args:
23 - # Self destruct!
24 - del aliases["deactivate"]
25 -
26 -
27 -# unset irrelevant variables
28 -_deactivate(["nondestructive"])
29 -aliases["deactivate"] = _deactivate
30 -
31 -$VIRTUAL_ENV = r"/mnt/c/_/PKH_Project1/web/env"
32 -
33 -$_OLD_VIRTUAL_PATH = $PATH
34 -$PATH = $PATH[:]
35 -$PATH.add($VIRTUAL_ENV + _get_sep() + "bin", front=True, replace=True)
36 -
37 -if ${...}.get("PYTHONHOME", ""):
38 - # unset PYTHONHOME if set
39 - $_OLD_VIRTUAL_PYTHONHOME = $PYTHONHOME
40 - del $PYTHONHOME
41 -
42 -$VIRTUAL_ENV_PROMPT = ""
43 -if not $VIRTUAL_ENV_PROMPT:
44 - del $VIRTUAL_ENV_PROMPT
45 -
46 -aliases["pydoc"] = ["python", "-m", "pydoc"]
1 -# -*- coding: utf-8 -*-
2 -"""Activate virtualenv for current interpreter:
3 -
4 -Use exec(open(this_file).read(), {'__file__': this_file}).
5 -
6 -This can be used when you must use an existing Python interpreter, not the virtualenv bin/python.
7 -"""
8 -import os
9 -import site
10 -import sys
11 -
12 -try:
13 - abs_file = os.path.abspath(__file__)
14 -except NameError:
15 - raise AssertionError("You must use exec(open(this_file).read(), {'__file__': this_file}))")
16 -
17 -bin_dir = os.path.dirname(abs_file)
18 -base = bin_dir[: -len("bin") - 1] # strip away the bin part from the __file__, plus the path separator
19 -
20 -# prepend bin to PATH (this file is inside the bin directory)
21 -os.environ["PATH"] = os.pathsep.join([bin_dir] + os.environ.get("PATH", "").split(os.pathsep))
22 -os.environ["VIRTUAL_ENV"] = base # virtual env is right above bin directory
23 -
24 -# add the virtual environments libraries to the host python import mechanism
25 -prev_length = len(sys.path)
26 -for lib in "../lib/python3.6/site-packages".split(os.pathsep):
27 - path = os.path.realpath(os.path.join(bin_dir, lib))
28 - site.addsitedir(path.decode("utf-8") if "" else path)
29 -sys.path[:] = sys.path[prev_length:] + sys.path[0:prev_length]
30 -
31 -sys.real_prefix = sys.prefix
32 -sys.prefix = base
1 -#!/mnt/c/_/PKH_Project1/web/env/bin/python
2 -# -*- coding: utf-8 -*-
3 -import re
4 -import sys
5 -from pip._internal.cli.main import main
6 -if __name__ == '__main__':
7 - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8 - sys.exit(main())
1 -/usr/bin/python3
...\ No newline at end of file ...\ No newline at end of file
1 -python
...\ No newline at end of file ...\ No newline at end of file
1 -python
...\ No newline at end of file ...\ No newline at end of file
1 -#!/mnt/c/_/PKH_Project1/web/env/bin/python
2 -# -*- coding: utf-8 -*-
3 -import re
4 -import sys
5 -from wheel.cli import main
6 -if __name__ == '__main__':
7 - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8 - sys.exit(main())
1 -#!/mnt/c/_/PKH_Project1/web/env/bin/python
2 -# -*- coding: utf-8 -*-
3 -import re
4 -import sys
5 -from wheel.cli import main
6 -if __name__ == '__main__':
7 - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8 - sys.exit(main())
1 -#!/mnt/c/_/PKH_Project1/web/env/bin/python
2 -# -*- coding: utf-8 -*-
3 -import re
4 -import sys
5 -from wheel.cli import main
6 -if __name__ == '__main__':
7 - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8 - sys.exit(main())
1 -home = /usr
2 -implementation = CPython
3 -version_info = 3.6.9.final.0
4 -virtualenv = 20.0.17
5 -include-system-site-packages = false
6 -base-prefix = /usr
7 -base-exec-prefix = /usr
8 -base-executable = /usr/bin/python3
1 -{
2 - "name": "front",
3 - "version": "0.1.0",
4 - "private": true,
5 - "scripts": {
6 - "serve": "vue-cli-service serve",
7 - "build": "vue-cli-service build",
8 - "lint": "vue-cli-service lint"
9 - },
10 - "dependencies": {
11 - "@mdi/font": "^3.6.95",
12 - "axios": "^0.19.2",
13 - "core-js": "^3.6.5",
14 - "filepond": "^4.13.4",
15 - "filepond-plugin-file-validate-type": "^1.2.5",
16 - "filepond-plugin-image-preview": "^4.6.2",
17 - "moment": "^2.24.0",
18 - "roboto-fontface": "*",
19 - "vue": "^2.6.11",
20 - "vue-filepond": "^6.0.2",
21 - "vue-router": "^3.1.6",
22 - "vuetify": "^2.2.11",
23 - "vuex": "^3.1.3"
24 - },
25 - "devDependencies": {
26 - "@vue/cli-plugin-babel": "~4.3.0",
27 - "@vue/cli-plugin-eslint": "~4.3.0",
28 - "@vue/cli-plugin-router": "~4.3.0",
29 - "@vue/cli-plugin-vuex": "~4.3.0",
30 - "@vue/cli-service": "~4.3.0",
31 - "@vue/eslint-config-airbnb": "^5.0.2",
32 - "babel-eslint": "^10.1.0",
33 - "eslint": "^6.7.2",
34 - "eslint-plugin-import": "^2.20.2",
35 - "eslint-plugin-vue": "^6.2.2",
36 - "node-sass": "^4.12.0",
37 - "sass": "^1.19.0",
38 - "sass-loader": "^8.0.2",
39 - "vue-cli-plugin-vuetify": "~2.0.5",
40 - "vue-template-compiler": "^2.6.11",
41 - "vuetify-loader": "^1.3.0"
42 - }
43 -}
1 -<template>
2 - <v-app>
3 - <v-app-bar app color="#ffffff" elevation="1" hide-on-scroll>
4 - <v-icon size="35" class="mr-1" color="grey700">mdi-youtube</v-icon>
5 - <div style="color: #343a40; font-size: 20px; font-weight: 500;">Youtube Auto Tagger</div>
6 - <v-spacer></v-spacer>
7 - <v-tooltip bottom>
8 - <template v-slot:activator="{ on }">
9 - <v-btn icon v-on="on" color="grey700" @click="clickInfo=true">
10 - <v-icon size="30">mdi-information</v-icon>
11 - </v-btn>
12 - </template>
13 - <span>Service Info</span>
14 - </v-tooltip>
15 - </v-app-bar>
16 - <v-dialog v-model="clickInfo" max-width="600" class="pa-2">
17 - <v-card elevation="0" outlined class="pa-4">
18 - <v-row justify="center" class="mx-0 mb-8 mt-2">
19 - <v-icon color="lightblue">mdi-power-on</v-icon>
20 - <div
21 - style="text-align: center; font-size: 22px; font-weight: 400; color: #343a40;"
22 - >Information of This Service</div>
23 - <v-icon color="lightblue">mdi-power-on</v-icon>
24 - </v-row>
25 - <div>Used Opensource</div>
26 - </v-card>
27 - </v-dialog>
28 - <v-content>
29 - <router-view />
30 - </v-content>
31 - <v-footer>
32 - <v-row justify="center">
33 - <v-avatar size="25" tile style="border-radius: 4px">
34 - <v-img src="./assets/logo.png"></v-img>
35 - </v-avatar>
36 - <a href="http://khuhub.khu.ac.kr/2020-1-capstone-design1/PKH_Project1">
37 - <div
38 - style="margin-left: 4px; font-size: 16px; color: #5a5a5a; font-weight: 400"
39 - >Profit-Hunter</div>
40 - </a>
41 - </v-row>
42 - </v-footer>
43 - </v-app>
44 -</template>
45 -<script>
46 -export default {
47 - name: 'App',
48 - data() {
49 - return {
50 - clickInfo: false,
51 - };
52 - },
53 -};
54 -</script>
55 -<style lang="scss">
56 -a:hover {
57 - text-decoration: none;
58 -}
59 -a:link {
60 - text-decoration: none;
61 -}
62 -a:visited {
63 - text-decoration: none;
64 -}
65 -</style>
1 -<template>
2 - <div>
3 - <file-pond
4 - name="bin"
5 - ref="pond"
6 - allow-multiple="false"
7 - accepted-file-types="video/mp4, video/avi"
8 - max-files="1"
9 - :server="server"
10 - v-bind:files="myFiles"
11 - v-on:init="handleFilePondInit"
12 - v-on:processfile="onload"
13 - />
14 - </div>
15 -</template>
16 -
17 -<script>
18 -// Import Vue FilePond
19 -import vueFilePond from 'vue-filepond';
20 -
21 -// Import FilePond styles
22 -import 'filepond/dist/filepond.min.css';
23 -
24 -// Import FilePond plugins
25 -// Please note that you need to install these plugins separately
26 -
27 -// Import image preview plugin styles
28 -import 'filepond-plugin-image-preview/dist/filepond-plugin-image-preview.min.css';
29 -
30 -// Import image preview and file type validation plugins
31 -import FilePondPluginFileValidateType from 'filepond-plugin-file-validate-type';
32 -import FilePondPluginImagePreview from 'filepond-plugin-image-preview';
33 -
34 -// Create component
35 -const FilePond = vueFilePond(
36 - FilePondPluginFileValidateType,
37 - FilePondPluginImagePreview,
38 -);
39 -
40 -export default {
41 - name: 'app',
42 - data() {
43 - return {
44 - myFiles: [],
45 - server: {
46 - url: `${this.$apiRootPath}upload/video`,
47 - process: {},
48 - },
49 - };
50 - },
51 - methods: {
52 - handleFilePondInit() {
53 - console.log('FilePond has initialized');
54 - // FilePond instance methods are available on `this.$refs.pond`
55 - },
56 - onload(e, r) {
57 - console.log(r);
58 - // this.$store.dispatch(r);
59 - },
60 - },
61 - components: {
62 - FilePond,
63 - },
64 -};
65 -</script>
66 -
67 -<style scoped>
68 -.filepond--item {
69 - width: calc(50% - 0.5em);
70 -}
71 -.filepond--panel-root {
72 - background-color: transparent;
73 - border: 2px solid #2c3340;
74 -}
75 -</style>
1 -import Vue from 'vue';
2 -import Vuetify from 'vuetify/lib';
3 -
4 -Vue.use(Vuetify);
5 -
6 -export default new Vuetify({
7 - theme: {
8 - themes: {
9 - light: {
10 - primary: '#343a40',
11 - secondary: '#506980',
12 - accent: '#505B80',
13 - error: '#FF5252',
14 - info: '#2196F3',
15 - blue: '#173f5f',
16 - lightblue: '#72b1e4',
17 - success: '#2779bd',
18 - warning: '#12283a',
19 - grey300: '#eceeef',
20 - grey500: '#aaaaaa',
21 - grey700: '#5a5a5a',
22 - grey900: '#212529',
23 - },
24 - dark: {
25 - primary: '#343a40',
26 - secondary: '#506980',
27 - accent: '#505B80',
28 - error: '#FF5252',
29 - info: '#2196F3',
30 - blue: '#173f5f',
31 - lightblue: '#72b1e4',
32 - success: '#2779bd',
33 - warning: '#12283a',
34 - grey300: '#eceeef',
35 - grey500: '#aaaaaa',
36 - grey700: '#5a5a5a',
37 - grey900: '#212529',
38 - },
39 - },
40 - },
41 -});
1 -import Vue from 'vue';
2 -import VueRouter from 'vue-router';
3 -import axios from 'axios';
4 -import Home from '../views/Home.vue';
5 -
6 -Vue.prototype.$axios = axios;
7 -const apiRootPath = process.env.NODE_ENV !== 'production'
8 - ? 'http://localhost:8000/api/'
9 - : '/api/';
10 -Vue.prototype.$apiRootPath = apiRootPath;
11 -axios.defaults.baseURL = apiRootPath;
12 -
13 -Vue.use(VueRouter);
14 -
15 -const routes = [
16 - {
17 - path: '/',
18 - name: 'Home',
19 - component: Home,
20 - },
21 -];
22 -
23 -const router = new VueRouter({
24 - mode: 'history',
25 - base: process.env.BASE_URL,
26 - routes,
27 -});
28 -
29 -export default router;
1 -<template>
2 - <v-sheet>
3 - <v-layout justify-center>
4 - <v-flex xs12 sm8 md6 lg4>
5 - <v-row justify="center" class="mx-0 mt-12">
6 - <div style="font-size: 34px; font-weight: 500; color: #343a40;">WELCOME</div>
7 - </v-row>
8 - <v-card elevation="0">
9 - <!-- file upload -->
10 - <v-row justify="center" class="mx-0 mt-12" v-if="$vuetify.breakpoint.mdAndUp">
11 - <v-flex md7 class="mt-1">
12 - <div
13 - style="font-size: 20px; font-weight: 300; color: #888;"
14 - >This is Video auto tagging Service</div>
15 - <div
16 - style="font-size: 20px; font-weight: 300; color: #888;"
17 - >Designed for Youtube Videos</div>
18 - <div
19 - style="font-size: 20px; font-weight: 300; color: #888;"
20 - >It takes few minutes to analyze your Video!</div>
21 - </v-flex>
22 - <v-flex md5>
23 - <v-card width="240" elevation="0" class="ml-5">
24 - <v-img width="240" src="../assets/youtubelogoBlack.png"></v-img>
25 - </v-card>
26 - </v-flex>
27 - </v-row>
28 - <v-card elevation="0" class="mt-8" v-else>
29 - <div
30 - style="font-size: 20px; font-weight: 300; color: #888; text-align: center"
31 - >This is Video auto tagging Service</div>
32 - <div
33 - style="font-size: 20px; font-weight: 300; color: #888; text-align: center"
34 - >Designed for Youtube Videos</div>
35 - <div
36 - style="font-size: 20px; font-weight: 300; color: #888; text-align: center"
37 - >It takes few minutes to analyze your Video!</div>
38 - <v-img
39 - style="margin: auto; margin-top: 20px"
40 - width="180"
41 - src="../assets/youtubelogoBlack.png"
42 - ></v-img>
43 - </v-card>
44 -
45 - <div
46 - class="mt-10"
47 - style="font-size: 24px; text-align: center; font-weight: 400; color: #5a5a5a;"
48 - >How To start this service</div>
49 - <div
50 - style="font-size: 20px; font-weight: 300; color: #888; text-align: center"
51 - >Just Upload your Video</div>
52 - <v-row justify="center" class="mx-0 mt-2">
53 - <v-flex xs12 md8>
54 - <div class="mx-8">
55 - <video-upload />
56 - </div>
57 - </v-flex>
58 - </v-row>
59 -
60 - <div
61 - style="font-size: 24px; text-align: center; font-weight: 400; color: #5a5a5a;"
62 - class="mt-10"
63 - >The Results of Analyzed Video</div>
64 - <v-card outlined class="pa-2 mx-5 mt-6" elevation="0" min-height="67">
65 - <div
66 - style="margin-left: 5px; margin-top: -18px; background-color: #fff; width: 110px; text-align: center;font-size: 14px; color: #5a5a5a; font-weight: 500"
67 - >Generated Tags</div>
68 - <v-chip-group column>
69 - <v-chip color="secondary" v-for="(tag, index) in generatedTag" :key="index">{{ tag }}</v-chip>
70 - </v-chip-group>
71 - </v-card>
72 - <v-card outlined class="pa-2 mx-5 mt-8" elevation="0" min-height="67">
73 - <div
74 - style="margin-left: 5px; margin-top: -18px; background-color: #fff; width: 140px; text-align: center;font-size: 14px; color: #5a5a5a; font-weight: 500"
75 - >Related Youtube Link</div>
76 - <v-flex v-for="(url) in YoutubeUrl" :key="url">
77 - <div>
78 - <a :href="url">{{url}}</a>
79 - </div>
80 - </v-flex>
81 - </v-card>
82 - <div
83 - class="mt-3"
84 - style="font-size: 20px; font-weight: 300; color: #888; text-align: center"
85 - >If the Video is analyzed successfully,</div>
86 - <div
87 - class="mb-5"
88 - style="font-size: 20px; font-weight: 300; color: #888; text-align: center"
89 - >Result Show up in each of Boxes!</div>
90 - </v-card>
91 - </v-flex>
92 - </v-layout>
93 - </v-sheet>
94 -</template>
95 -<script>
96 -import videoUpload from '../components/uploadFile.vue';
97 -
98 -export default {
99 - name: 'Home',
100 - components: {
101 - videoUpload,
102 - },
103 - data() {
104 - return {
105 - myFiles: [],
106 - YoutubeUrl: [],
107 - generatedTag: [],
108 - successDialog: false,
109 - errorDialog: false,
110 - loading: false,
111 - };
112 - },
113 - created() {
114 - this.YoutubeUrl = [];
115 - this.generatedTag = [];
116 - },
117 -
118 - methods: {
119 - loadVideoInfo() {},
120 - },
121 -};
122 -</script>
1 -module.exports = {
2 - transpileDependencies: [
3 - 'vuetify',
4 - ],
5 -};
1 -# front 1 +# frontend
2 2
3 ## Project setup 3 ## Project setup
4 ``` 4 ```
......
1 module.exports = { 1 module.exports = {
2 - presets: [ 2 + presets: ["@vue/cli-plugin-babel/preset"]
3 - '@vue/cli-plugin-babel/preset',
4 - ],
5 }; 3 };
......
1 +{
2 + "name": "frontend",
3 + "version": "0.1.0",
4 + "private": true,
5 + "scripts": {
6 + "serve": "vue-cli-service serve",
7 + "build": "vue-cli-service build",
8 + "lint": "vue-cli-service lint"
9 + },
10 + "dependencies": {
11 + "@mdi/font": "^5.0.45",
12 + "axios": "^0.19.2",
13 + "core-js": "^3.6.4",
14 + "filepond": "^4.13.0",
15 + "filepond-plugin-file-validate-type": "^1.2.5",
16 + "filepond-plugin-image-preview": "^4.6.1",
17 + "moment": "^2.24.0",
18 + "roboto-fontface": "*",
19 + "vee-validate": "^3.2.5",
20 + "vue": "^2.6.11",
21 + "vue-filepond": "^6.0.2",
22 + "vue-infinite-scroll": "^2.0.2",
23 + "vue-router": "^3.1.5",
24 + "vue-video-player": "^5.0.2",
25 + "vuetify": "^2.2.11",
26 + "vuex": "^3.1.2"
27 + },
28 + "devDependencies": {
29 + "@vue/cli-plugin-babel": "~4.2.0",
30 + "@vue/cli-plugin-eslint": "~4.2.0",
31 + "@vue/cli-plugin-router": "~4.2.0",
32 + "@vue/cli-plugin-vuex": "~4.2.0",
33 + "@vue/cli-service": "~4.2.0",
34 + "@vue/eslint-config-prettier": "^6.0.0",
35 + "babel-eslint": "^10.0.3",
36 + "eslint": "^6.7.2",
37 + "eslint-plugin-prettier": "^3.1.1",
38 + "eslint-plugin-vue": "^6.1.2",
39 + "node-sass": "^4.12.0",
40 + "prettier": "^1.19.1",
41 + "sass": "^1.19.0",
42 + "sass-loader": "^8.0.2",
43 + "vue-cli-plugin-vuetify": "~2.0.5",
44 + "vue-template-compiler": "^2.6.11",
45 + "vuetify-loader": "^1.3.0"
46 + },
47 + "eslintConfig": {
48 + "root": true,
49 + "env": {
50 + "node": true
51 + },
52 + "extends": [
53 + "plugin:vue/essential",
54 + "eslint:recommended",
55 + "@vue/prettier"
56 + ],
57 + "parserOptions": {
58 + "parser": "babel-eslint"
59 + },
60 + "rules": {}
61 + },
62 + "browserslist": [
63 + "> 1%",
64 + "last 2 versions"
65 + ]
66 +}
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 -<html lang="en"> 2 +<html lang="ko">
3 <head> 3 <head>
4 <meta charset="utf-8"> 4 <meta charset="utf-8">
5 <meta http-equiv="X-UA-Compatible" content="IE=edge"> 5 <meta http-equiv="X-UA-Compatible" content="IE=edge">
......
1 +<template>
2 + <v-app>
3 + <v-app-bar app color="#ffffff" elevation="1">
4 + <v-tabs grow v-model="tab">
5 + <v-tab @click="$router.push('/')">Home</v-tab>
6 + <v-tab @click="$router.push('/upload')">Upload</v-tab>
7 + </v-tabs>
8 + </v-app-bar>
9 + <v-content>
10 + <router-view />
11 + </v-content>
12 + <v-footer>
13 + <v-row justify="center" @click="exDialog = true">
14 + <v-avatar size="25" tile style="border-radius: 4px">
15 + <v-img src="./assets/logo.png"></v-img>
16 + </v-avatar>
17 + <div>
18 + <span
19 + style="margin-left: 2px; font-size: 15px; color: #5a5a5a; font-weight: 400"
20 + >
21 + Profit-Hunter
22 + </span>
23 + <div
24 + style="margin-left: 4px; margin-top: -1px; font-size: 10px; color: #888; font-weight: 400"
25 + >
26 + Used OpenSource
27 + </div>
28 + </div>
29 + </v-row>
30 + </v-footer>
31 + </v-app>
32 +</template>
33 +
34 +<script>
35 +export default {
36 + name: "App",
37 +
38 + data: () => ({
39 + tab: null,
40 + search: "",
41 + exDialog: false
42 + }),
43 + mounted() {
44 + console.log(window.location.href.substring(22));
45 + if (window.location.href.substring(22) === "") {
46 + this.tab = 0;
47 + } else if (window.location.href.substring(22) === "upload") {
48 + this.tab = 1;
49 + } else {
50 + this.tab = null;
51 + }
52 + }
53 +};
54 +</script>
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.