-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
98 additions
and
7 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
CLOUDINARY_CLOUD_NAME=cccccccccccc | ||
CLOUDINARY_API_KEY=ccccccccccccccc | ||
CLOUDINARY_API_SECRET=ccccccccccccc |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Generated by Django 4.1.3 on 2023-02-13 03:09 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Image', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('image_url', models.URLField()), | ||
], | ||
), | ||
] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
from django.db import models | ||
|
||
# Create your models here. | ||
class Image(models.Model): | ||
image_url = models.URLField() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
from django.urls import path | ||
from django.contrib.auth import views | ||
from apps.core.views import logout_view, UsersList | ||
from apps.core.views import ImageViewSet, logout_view, UsersList | ||
|
||
urlpatterns = [ | ||
path('api/v1/auth/logout/', logout_view, name='logout'), | ||
path('api/users/', UsersList.as_view(), name='api_get_users'), | ||
path('api/upload_image/', ImageViewSet.as_view({'post': 'upload_image'}), name='api_upload_image'), | ||
] |
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 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<template> | ||
<div> | ||
<input type="file" @change="uploadImage"/> | ||
<img v-if="imageUrl" :src="imageUrl"/> | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
import axios from 'axios' | ||
import { ref } from 'vue' | ||
const imageUrl = ref(''); | ||
async function uploadImage(event){ | ||
const file = event.target.files[0]; | ||
const formData = new FormData(); | ||
formData.append('file', file); | ||
await axios.post('/api/upload_image/', formData) | ||
.then(response => { | ||
imageUrl.value = response.data['image_url'] | ||
}) | ||
.catch(error => { | ||
console.log('error' + error) | ||
}) | ||
} | ||
</script> |
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 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