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 { createReadStream } from 'fs' | |
import { basename } from 'path' | |
import * as request from 'request' // npm i request | |
import * as Throttle from 'throttle' // npm install throttle | |
const fileToUploadPath = '/foo.txt' | |
const fileSize = 1024 // Computed with 'fs.stat' for example | |
request.post( | |
'/upload', |
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
const myMethod = require('./module') | |
// or | |
import myMethod from './module' |
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 asyncio | |
import streamlit as st | |
from httpx_oauth.clients.google import GoogleOAuth2 | |
st.title("Google OAuth2 flow") | |
"## Configuration" | |
client_id = st.text_input("Client ID") |
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 | |
from datetime import datetime | |
from jwcrypto import jwt, jwk # pip install jwcrypto | |
b64_jwk = "XXXX" # Base64-encoded JWT you get from Cloudflare Stream API (https://developers.cloudflare.com/stream/viewing-videos/securing-your-stream#step-1-call-the-streamkey-endpoint-once-to-obtain-a-key) | |
jwk_key = jwk.JWK.from_json(base64.b64decode(b64_jwk)) | |
def get_video_token(video_id: str, lifetime: int = 3600) -> str: | |
header = {"kid": jwk_key["kid"], "alg": "RS256"} |
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 enum import StrEnum | |
from fastapi import FastAPI | |
from .sorting import Sorting | |
class SortingField(StrEnum): | |
FIELD_A = "field_a" | |
FIELD_B = "field_b" |