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
import json | |
from rest_framework.test import APIClient | |
class TestClass(): | |
def setUp(): | |
self.client = APIClient() | |
self.register_url=reverse('authentication:register') | |
def test_create_user(self): | |
"""Tests if a user can create an account""" | |
valid_register_data = { | |
'user': { |
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
Step 1 #Provide a title in the route configuration,Usually in the app.module.ts | |
{ path: '', component: HomeComponent, data: { title: 'welcome' } }, | |
Step 2 #import {ActivatedRoute } from '@angular/router'; | |
Step 3 #Inject the ActivatedRoute interface in the constructor of your component: | |
constructor(private router:ActivatedRoute) { } | |
Step 4,#Subscribe to the data observable and pull out your data variables,use them for what you want. | |
ngOnInit() { |
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 flask_mail import Mail, Message | |
from flask import Flask | |
app = Flask(__name__) | |
app.config.update( | |
DEBUG=True, | |
#EMAIL SETTINGS | |
MAIL_SERVER='smtp.gmail.com', | |
MAIL_PORT=465, | |
MAIL_USE_SSL=True, | |
MAIL_USERNAME = 'your email', |
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
[ | |
{ | |
"name":"Afghanistan", | |
"code":"AF", | |
"continent":"Asia", | |
"filename":"afghanistan" | |
}, | |
{ | |
"name":"Åland Islands", | |
"continent":"Europe", |
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.http import JsonResponse | |
def error_404(request, exception): | |
message = ("The endpoint you are trying to access might " | |
"have been removed, " | |
"had its name changed, or is temporarily unavailable. " | |
"Please check the documentation here : " | |
"/ docs and try again later.") | |
response = JsonResponse(data={"message": message, 'status_code': 404}) |
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.views import exception_handler | |
from rest_framework import status | |
from django.http import Http404 | |
def custom_exception_handler(exc, context): | |
""" | |
This function will handle errors that are returned by | |
the different views. | |
The `handlers` dictionary will map |
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
import React, { useState } from "react"; | |
import "./App.css"; | |
function App() { | |
const [form, setForm] = useState([]); | |
const [submitted, setFormSubmitted] = useState(false); | |
const someEmpty = form.some( | |
(item) => item.Platform === "" || item.Username === "" | |
); |
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
import React, { useState } from "react"; | |
import "./style.css"; | |
const DynamicHeightInput = () => { | |
const [textareaHeight, setTextareaHeight] = useState(42); | |
const [formValue, setFormValue] = useState({}); | |
const onChange = (event) => { | |
event.preventDefault(); | |
event.persist(); |
OlderNewer