Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 base64 | |
import cffi | |
ffi = cffi.FFI() | |
ffi.cdef(""" | |
typedef struct bio_st BIO; | |
typedef struct bio_method_st BIO_METHOD; | |
typedef struct env_md_st EVP_MD; | |
typedef struct ssl_ctx_st SSL_CTX; | |
typedef struct ssl_method_st SSL_METHOD; |
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
export class Page<T> { | |
count: number; // total number of items | |
next: string; // URL of the next page | |
previous: string; // URL of the previous page | |
results: Array<T>; // items for the current page | |
} |
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
export function queryPaginated<T>(http: HttpClient, baseUrl: string, urlOrFilter?: string | object): Observable<Page<T>> { | |
let params = new HttpParams(); | |
let url = baseUrl; | |
if (typeof urlOrFilter === 'string') { | |
// we were given a page URL, use it | |
url = urlOrFilter; | |
} else if (typeof urlOrFilter === 'object') { | |
// we were given filtering criteria, build the query string | |
Object.keys(urlOrFilter).sort().forEach(key => { |
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
export class Pony { | |
id: number; | |
is_available: boolean; | |
name: string; | |
} | |
@Injectable() | |
export class PonyService { | |
baseUrl = 'http://localhost:8000/v1/ponies'; |
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
@Component({ | |
selector: 'app-pony-list', | |
templateUrl: './pony-list.component.html', | |
styleUrls: ['./pony-list.component.css'] | |
}) | |
export class PonyListComponent { | |
filterForm: FormGroup; | |
page: Observable<Page<Pony>> | |
pageUrl = new Subject<string>(); |
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
<div class="container" [formGroup]="filterForm"> | |
<div class="search-bar"> | |
<input formControlName="search" placeholder="Search by pony name"> | |
<select formControlName="is_available"> | |
<option [value]="null">Is available?</option> | |
<option [value]="true">Yes</option> | |
<option [value]="false">No</option> | |
</select> | |
</div> |
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 urllib.parse import quote | |
def add_content_disposition_header(response, filename): | |
""" | |
Add an RFC5987 / RFC6266 compliant Content-Disposition header to an | |
HttpResponse to tell the browser to save the HTTP response to a file. | |
""" | |
try: | |
filename.encode('ascii') |
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
HTTP/1.1 200 OK | |
Content-Disposition: attachment; filename="somefile.pdf" | |
Content-Length: 12345 | |
Content-Type: application/pdf |
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
HTTP/1.1 200 OK | |
Content-Disposition: attachment; filename*=utf-8''s%C3%B6mefil%C3%AA.xlsx" | |
Content-Length: 12345 | |
Content-Type: application/pdf |
OlderNewer