This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var htmlmin = require('gulp-htmlmin'); | |
var cleanCSS = require('gulp-clean-css'); | |
var minify = require('gulp-minify'); | |
const gulp = require('gulp'), | |
del = require('del'), | |
runSequence = require('run-sequence'), | |
src = `${__dirname}/.`, | |
dist = `${__dirname}/public`; | |
workbox = require('workbox-build'); | |
imagemin = require('gulp-imagemin'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stages: | |
- deploy | |
deploy_prod: | |
stage: deploy | |
script: | |
- rm -r Web/public | |
- cd Web | |
- npm install | |
- gulp build && gulp generate-service-worker && gulp minify_html && gulp minify-css && gulp minify_js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was created because you tired to download from a localhost in docker. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from rest_framework.serializers import ModelSerializer, SerializerMethodField | |
from .models import Book, Publisher, Author | |
class PublisherModelSerializer(ModelSerializer): | |
""" | |
A ModelSerializer that takes an additional `fields` argument that | |
controls which fields should be displayed. | |
""" | |
def __init__(self, *args, **kwargs): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
# Create your models here. | |
class Publisher(models.Model): | |
name = models.CharField(max_length=30, blank=False) | |
address = models.CharField(max_length=50, blank=False) | |
city = models.CharField(max_length=60, blank=False) | |
state_province = models.CharField(max_length=30, blank=False) | |
country = models.CharField(max_length=50, blank=False) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from rest_framework.viewsets import ModelViewSet | |
from rest_framework.authentication import SessionAuthentication | |
from .serializers import BookModelSerializer | |
from .models import Book | |
# Create your views here. | |
class BookModelViewSet(ModelViewSet): | |
""" | |
A simple ViewSet for viewing and editing books. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from rest_framework.routers import DefaultRouter | |
from .views import BookModelViewSet | |
router = DefaultRouter(trailing_slash=False) | |
router.register(r'book', BookModelViewSet, base_name='book') | |
urlpatterns = router.urls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BookModelSerializer(ModelSerializer): | |
authors = SerializerMethodField("get_author_serializer") | |
publisher = SerializerMethodField("get_publisher_serializer") | |
class Meta: | |
model = Book | |
fields = '__all__' | |
def get_author_serializer(self, obj): | |
request = self.context.get('request') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from rest_framework.viewsets import ViewSet | |
from rest_framework.response import Response | |
from .serializers import UploadSerializer | |
# ViewSets define the view behavior. | |
class UploadViewSet(ViewSet): | |
serializer_class = UploadSerializer | |
def list(self, request): | |
return Response("GET API") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from rest_framework.serializers import Serializer, FileField | |
# Serializers define the API representation. | |
class UploadSerializer(Serializer): | |
file_uploaded = FileField() | |
class Meta: | |
fields = ['file_uploaded'] |
OlderNewer