찾다
백엔드 개발파이썬 튜토리얼Django, Twilio 및 Pinata를 사용하여 안전한 익명 피드백 시스템 구축

In this guide, I will walk you through building a Secure Anonymous Feedback System using Django, Twilio for SMS notifications, Pinata for secure media uploads, and TailwindCSS for responsive styling. By the end of this tutorial, you will have a fully functional feedback system where users can submit feedback, optionally upload media, and receive SMS notifications—all with security and privacy in mind.

Demo: Live Link

Key Features:

  • Anonymous Feedback Submission: Users can submit feedback or support requests anonymously.
  • Secure Media Uploads: Users can upload media files securely via Pinata, stored on IPFS.
  • Twilio SMS Notifications: Automatically sends SMS confirmation to users via Twilio.
  • Responsive UI: Styled with TailwindCSS for a seamless, modern design.

Technologies Used:

  • Django: Backend framework for the feedback system.
  • Twilio: Handles SMS notifications.
  • Pinata: Provides IPFS-based secure media storage.
  • TailwindCSS: For responsive frontend styling.

Step 1: Project Setup and Dependencies

1.1. Create and Set Up a Virtual Environment
Start by setting up your project environment. Ensure you have Python installed and set up a virtual environment:


python3 -m venv venv
source venv/bin/activate


On Windows:


venv\Scripts\activate


Install the necessary packages:


pip install django twilio python-decouple requests gunicorn


1.2. Start a Django Project
Initialize a new Django project and app:


django-admin startproject config .
python manage.py startapp feedback


Step 2: Build the Feedback Submission System

2.1. Create a Feedback Model
Define a model to store feedback submissions in feedback/models.py:


from django.db import models

class Feedback(models.Model):
    message = models.TextField()
    sender_email = models.EmailField()
    sender_phone = models.CharField(max_length=15)
    media_url = models.URLField(null=True, blank=True)
    created_at = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return f"Feedback from {self.sender_email}"


This model captures feedback, email, phone number, and optional media URLs.

2.2. Create Views for Handling Feedback and SMS Notifications
In feedback/views.py, create views to process feedback and send SMS notifications:


from django.shortcuts import render
from django.http import HttpResponse
from .models import Feedback
from twilio.rest import Client
from django.conf import settings
import requests

def upload_to_pinata(file):
    url = "https://api.pinata.cloud/pinning/pinFileToIPFS"
    headers = {
        'pinata_api_key': settings.PINATA_API_KEY,
        'pinata_secret_api_key': settings.PINATA_SECRET_API_KEY,
    }
    files = {'file': file}
    response = requests.post(url, files=files, headers=headers)
    return response.json().get('IpfsHash')

def submit_feedback(request):
    if request.method == 'POST':
        message = request.POST.get('message')
        sender_email = request.POST.get('sender_email')
        sender_phone = request.POST.get('sender_phone')
        file = request.FILES.get('media_file', None)

        media_url = None
        if file:
            media_url = upload_to_pinata(file)

        feedback = Feedback.objects.create(
            message=message,
            sender_email=sender_email,
            sender_phone=sender_phone,
            media_url=media_url
        )

        # Send SMS using Twilio
        client = Client(settings.TWILIO_ACCOUNT_SID, settings.TWILIO_AUTH_TOKEN)
        client.messages.create(
            body=f"Feedback received from {sender_phone}: {message}",
            from_=settings.TWILIO_PHONE_NUMBER,
            to=sender_phone
        )

        return HttpResponse("Feedback submitted successfully!")

    return render(request, 'feedback_form.html')


This view handles form submissions, uploads optional media to Pinata, and sends SMS using Twilio.

2.3. Creating the Feedback Form
Create an HTML form to submit feedback. In your templates folder, create feedback_form.html:


{% load static %}



    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Submit Feedback</title>
    <link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">


    <div class="container mx-auto px-4 py-6">
        <h1 id="Submit-Feedback">Submit Feedback</h1>
        <form method="POST" action="" enctype="multipart/form-data" class="bg-white p-6 rounded shadow-md">
            {% csrf_token %}
            <div class="mb-4">
                <label for="message" class="block text-lg font-semibold">Your Feedback</label>
                <textarea name="message" id="message" class="w-full p-2 border rounded" required></textarea>
            </div>
            <div class="mb-4">
                <label for="sender_email" class="block text-lg font-semibold">Your Email</label>
                <input type="email" name="sender_email" id="sender_email" class="w-full p-2 border rounded" required>
            </div>
            <div class="mb-4">
                <label for="sender_phone" class="block text-lg font-semibold">Your Phone Number</label>
                <input type="tel" name="sender_phone" id="sender_phone" class="w-full p-2 border rounded" required>
            </div>
            <div class="mb-4">
                <label for="media_file" class="block text-lg font-semibold">Upload Media (Optional)</label>
                <input type="file" name="media_file" id="media_file" class="w-full p-2 border rounded">
            </div>
            <div class="text-center">
                <button type="submit" class="bg-blue-500 text-white px-4 py-2 rounded">Submit</button>
            </div>
        </form>
    </div>




Building a Secure Anonymous Feedback System with Django, Twilio, and Pinata
Image of the Front end

Building a Secure Anonymous Feedback System with Django, Twilio, and Pinata
Image of Pinata Dashboard showing the files uploaded

Step 3: Configuring Twilio and Pinata

3.1. Set Up Environment Variables
Create a .env file in your project’s root directory to store sensitive information like Twilio and Pinata API keys:


SECRET_KEY=your-django-secret-key
DEBUG=True

TWILIO_ACCOUNT_SID=your_twilio_account_sid
TWILIO_AUTH_TOKEN=your_twilio_auth_token
TWILIO_PHONE_NUMBER=your_twilio_phone_number

PINATA_API_KEY=your_pinata_api_key
PINATA_SECRET_API_KEY=your_pinata_secret_api_key


Make sure to add .env to your .gitignore file so it won’t be pushed to GitHub:


.env


3.2. Update settings.py to Use Environment Variables
Use python-decouple to securely load environment variables from the .env file:


from decouple import config

SECRET_KEY = config('SECRET_KEY')
DEBUG = config('DEBUG', default=False, cast=bool)

TWILIO_ACCOUNT_SID = config('TWILIO_ACCOUNT_SID')
TWILIO_AUTH_TOKEN = config('TWILIO_AUTH_TOKEN')
TWILIO_PHONE_NUMBER = config('TWILIO_PHONE_NUMBER')

PINATA_API_KEY = config('PINATA_API_KEY')
PINATA_SECRET_API_KEY = config('PINATA_SECRET_API_KEY')


Step 4: Pushing to GitHub

4.1. Initialize Git and Push to GitHub

  1. Initialize a Git repository in the root of your project:

git init
git add .
git commit -m "Initial commit for feedback system"


  1. Add your GitHub repository as a remote and push your project:

<p>git remote add origin https://github.com/yourusername/feedback-system.git<br>
git push -u origin main</p>




Conclusion

In this tutorial, you’ve built a secure anonymous feedback system using Django, Twilio for SMS notifications, and Pinata for media uploads. You’ve also learned how to push your project to GitHub and secure sensitive information using environment variables. This system ensures privacy while enabling users to submit feedback and receive SMS notifications.

Feel free to expand the system further by adding more features or enhancing security. If you found this guide helpful, share your feedback or questions in the comments!

The Repo to the Project can be found here: Repo

위 내용은 Django, Twilio 및 Pinata를 사용하여 안전한 익명 피드백 시스템 구축의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
Python의 병합 목록 : 올바른 메소드 선택Python의 병합 목록 : 올바른 메소드 선택May 14, 2025 am 12:11 AM

Tomergelistsinpython, youcanusethe operator, extendmethod, listcomprehension, oritertools.chain, 각각은 각각의 지위를 불러 일으킨다

Python 3에서 두 목록을 연결하는 방법은 무엇입니까?Python 3에서 두 목록을 연결하는 방법은 무엇입니까?May 14, 2025 am 12:09 AM

Python 3에서는 다양한 방법을 통해 두 개의 목록을 연결할 수 있습니다. 1) 작은 목록에 적합하지만 큰 목록에는 비효율적입니다. 2) 메모리 효율이 높지만 원래 목록을 수정하는 큰 목록에 적합한 확장 방법을 사용합니다. 3) 원래 목록을 수정하지 않고 여러 목록을 병합하는 데 적합한 * 운영자 사용; 4) 메모리 효율이 높은 대형 데이터 세트에 적합한 itertools.chain을 사용하십시오.

Python은 문자열을 연결합니다Python은 문자열을 연결합니다May 14, 2025 am 12:08 AM

join () 메소드를 사용하는 것은 Python의 목록에서 문자열을 연결하는 가장 효율적인 방법입니다. 1) join () 메소드를 사용하여 효율적이고 읽기 쉽습니다. 2)주기는 큰 목록에 비효율적으로 운영자를 사용합니다. 3) List Comprehension과 Join ()의 조합은 변환이 필요한 시나리오에 적합합니다. 4) READE () 방법은 다른 유형의 감소에 적합하지만 문자열 연결에 비효율적입니다. 완전한 문장은 끝납니다.

파이썬 실행, 그게 뭐야?파이썬 실행, 그게 뭐야?May 14, 2025 am 12:06 AM

pythonexecutionissprocessoftransformingpythoncodeintoExecutableInstructions.1) the -interreadsTheCode, ConvertingItintoByTecode, thethepythonVirtualMachine (pvm)을 실행합니다

파이썬 : 주요 기능은 무엇입니까?파이썬 : 주요 기능은 무엇입니까?May 14, 2025 am 12:02 AM

Python의 주요 특징은 다음과 같습니다. 1. 구문은 간결하고 이해하기 쉽고 초보자에게 적합합니다. 2. 개발 속도 향상, 동적 유형 시스템; 3. 여러 작업을 지원하는 풍부한 표준 라이브러리; 4. 광범위한 지원을 제공하는 강력한 지역 사회와 생태계; 5. 스크립팅 및 빠른 프로토 타이핑에 적합한 해석; 6. 다양한 프로그래밍 스타일에 적합한 다중-파라 디그 지원.

파이썬 : 컴파일러 또는 통역사?파이썬 : 컴파일러 또는 통역사?May 13, 2025 am 12:10 AM

Python은 해석 된 언어이지만 편집 프로세스도 포함됩니다. 1) 파이썬 코드는 먼저 바이트 코드로 컴파일됩니다. 2) 바이트 코드는 Python Virtual Machine에 의해 해석되고 실행됩니다. 3)이 하이브리드 메커니즘은 파이썬이 유연하고 효율적이지만 완전히 편집 된 언어만큼 빠르지는 않습니다.

루프 대 루프를위한 파이썬 : 루프시기는 언제 사용해야합니까?루프 대 루프를위한 파이썬 : 루프시기는 언제 사용해야합니까?May 13, 2025 am 12:07 AM

USEAFORLOOPHENTERATINGOVERASERASERASPECIFICNUMBEROFTIMES; USEAWHILLOOPWHENTINUTIMONDITINISMET.FORLOOPSAREIDEALFORKNOWNSEDINGENCENCENS, WHILEWHILELOOPSSUITSITUATIONS WITHERMINGEDERITERATIONS.

파이썬 루프 : 가장 일반적인 오류파이썬 루프 : 가장 일반적인 오류May 13, 2025 am 12:07 AM

Pythonloopscanleadtoerrors likeinfiniteloops, modifyinglistsdizeration, off-by-by-byerrors, zero-indexingissues, andnestedloopineficiencies.toavoidthese : 1) aing'i

See all articles

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

Video Face Swap

Video Face Swap

완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

뜨거운 도구

안전한 시험 브라우저

안전한 시험 브라우저

안전한 시험 브라우저는 온라인 시험을 안전하게 치르기 위한 보안 브라우저 환경입니다. 이 소프트웨어는 모든 컴퓨터를 안전한 워크스테이션으로 바꿔줍니다. 이는 모든 유틸리티에 대한 액세스를 제어하고 학생들이 승인되지 않은 리소스를 사용하는 것을 방지합니다.

DVWA

DVWA

DVWA(Damn Vulnerable Web App)는 매우 취약한 PHP/MySQL 웹 애플리케이션입니다. 주요 목표는 보안 전문가가 법적 환경에서 자신의 기술과 도구를 테스트하고, 웹 개발자가 웹 응용 프로그램 보안 프로세스를 더 잘 이해할 수 있도록 돕고, 교사/학생이 교실 환경 웹 응용 프로그램에서 가르치고 배울 수 있도록 돕는 것입니다. 보안. DVWA의 목표는 다양한 난이도의 간단하고 간단한 인터페이스를 통해 가장 일반적인 웹 취약점 중 일부를 연습하는 것입니다. 이 소프트웨어는

VSCode Windows 64비트 다운로드

VSCode Windows 64비트 다운로드

Microsoft에서 출시한 강력한 무료 IDE 편집기

SublimeText3 중국어 버전

SublimeText3 중국어 버전

중국어 버전, 사용하기 매우 쉽습니다.

SublimeText3 Mac 버전

SublimeText3 Mac 버전

신 수준의 코드 편집 소프트웨어(SublimeText3)