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 typing import Dict | |
from pprint import pprint | |
def parse_dataset(filename: str) -> Dict[str, str]: | |
data = {} | |
with open(filename) as f: | |
for line in f: | |
line = line.rstrip() | |
if line.startswith(">"): |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title>DJ Book Search</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | |
<link type="text/css" rel="stylesheet" href="//unpkg.com/bootstrap/dist/css/bootstrap.min.css" /> | |
<link type="text/css" rel="stylesheet" href="//unpkg.com/bootstrap-vue@latest/dist/bootstrap-vue.min.css" /> | |
</head> | |
<body> |
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.views import View | |
from django.http import JsonResponse | |
from django.views.generic import TemplateView | |
from book.search import search | |
class IndexView(TemplateView): | |
template_name = 'index.html' |
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 typing import Dict, List, Union | |
from django.conf import settings | |
from requests import get | |
from urllib.parse import urlencode | |
BASE_URL = 'https://www.googleapis.com/books/v1/volumes' | |
DEFAULT_THUMBNAIL = {'thumbnail': 'https://bit.ly/2NG0A8J'} |
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.conf import settings | |
from django.dispatch import receiver | |
from django.db.models.signals import post_save | |
from rest_framework.authtoken.models import Token | |
@receiver(post_save, sender=settings.AUTH_USER_MODEL) | |
def create_auth_token(sender, instance=None, created=False, **kwargs): | |
if created: |
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 from "react"; | |
import { useUsername } from "../store/auth/hooks"; | |
function Account() { | |
const username = useUsername(); | |
return <h2>Welcome, {username}</h2>; | |
} |
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
interface TokenResponse { | |
token: string; | |
} | |
export interface Credentials { | |
username: string; | |
password: string; | |
} | |
const BASE_URL = "http://localhost:8000"; |
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 { Redirect } from "react-router-dom"; | |
import { useDispatch } from "react-redux"; | |
import { logIn } from "../store/auth/actions"; | |
import { Credentials, getToken } from "../api/auth"; | |
import { useAuthenticated } from "../store/auth/hooks"; | |
function Login() { |
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 from "react"; | |
import { Route, Redirect } from "react-router-dom"; | |
import { useAuthenticated } from "../store/auth/hooks"; | |
function PrivateRoute({ | |
children, | |
...rest | |
}: { | |
children: JSX.Element | JSX.Element[]; |