Initial commit with the basics
This commit is contained in:
52
app/lib_general.py
Normal file
52
app/lib_general.py
Normal file
@@ -0,0 +1,52 @@
|
||||
from datetime import datetime, time, timedelta
|
||||
from fastapi import APIRouter, Depends, Header, HTTPException, status
|
||||
from pydantic import BaseModel, EmailStr, Field
|
||||
from typing import Dict, List, Optional, Set, Union
|
||||
|
||||
|
||||
#router = APIRouter()
|
||||
|
||||
#import app
|
||||
|
||||
async def get_token_header(x_token: str = Header(...)):
|
||||
if x_token != 'fake-super-secret-token':
|
||||
raise HTTPException(status_code=400, detail='X-Token header invalid')
|
||||
|
||||
|
||||
async def get_account_header(x_account_id: str = Header(...)):
|
||||
print('get_account_header(): '+x_account_id)
|
||||
return x_account_id
|
||||
|
||||
|
||||
#Add the processing time to the response header.
|
||||
#@app.middleware('http')
|
||||
#async def add_process_time_header(request: Request, call_next):
|
||||
#import time
|
||||
#start_time = time.time()
|
||||
#response = await call_next(request)
|
||||
#process_time = time.time() - start_time
|
||||
#response.headers['X-Process-Time'] = str(process_time)
|
||||
#return response
|
||||
|
||||
|
||||
#async def get_token_header(x_token: str = Header(...)):
|
||||
#if x_token != 'fake-super-secret-token':
|
||||
#raise HTTPException(status_code=400, detail='X-Token header invalid')
|
||||
|
||||
|
||||
#async def get_account_header(x_account_id: str = Header(...)):
|
||||
#@app.middleware("http")
|
||||
#async def get_account_header(x_account_id: str = Header(...)):
|
||||
#return x_account_id
|
||||
#x_account_id: str = Header(...)
|
||||
#x_account_id = 'static random ID...'
|
||||
#response = await call_next(request)
|
||||
|
||||
#print(x_account_id)
|
||||
|
||||
#return x_account_id
|
||||
|
||||
|
||||
#async def get_account_header(x_account_id: str = Header(...)):
|
||||
#print('get_account_header(): '+x_account_id+'z9999z')
|
||||
#return x_account_id+'z9999z'
|
||||
Reference in New Issue
Block a user