Yoonjunhyeon

backend 파일 업로드 완료

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