authors:
- frank tags:
- Python
- Unicode
- ctypes description: Python Unicode keywords:
- Python Unicode
"""A simple whoami server to analyze incoming HTTP requests | |
# For simplicity, we don't do: | |
# 1. Detect End of HTTP Request either by double CRLF(`\r\n\r\n`) or `Content-Length`. | |
# 2. Parse the HTTP request message. | |
# Instead, we just do: | |
# 1. Read max size of `GET` and `POST` requests data is 4096 bytes. | |
# 2. Close the connection for each request. | |
""" |
authors:
|
""" | |
DICOM files --> vtk array --> vtk 3D visualization | |
1. read a series of DICOM files by vtkDICOMImageReader(which will do HU and don't resample) | |
2. process vtk 3D array with marching cubes algorithm | |
3. render vtk 3D array | |
""" | |
import vtk | |
from utils import CreateTissue | |
DICOM Processing and Segmentation in Python – Radiology Data Quest Advanced DICOM-CT 3D visualizations with VTK | Kaggle Pulmonary Dicom Preprocessing | Kaggle How to actually to convert 3d numpy array of DICOM images into vtkImageData and vtkAlgorithmOutput? - #2 by dgobbi - Support - VTK
""" | |
Serving long-running/heavy-computation task via FastAPI and concurrent.futures.ProcessPoolExecutor | |
usage: | |
```sh | |
uvicorn main:app --reload | |
``` | |
""" | |
from fastapi import FastAPI |
""" | |
Serving long-running/heavy-computation task via FastAPI and multiprocessing.Process | |
usage: | |
```sh | |
uvicorn main:app --reload | |
``` | |
""" | |
from fastapi import FastAPI |
# Show available `presets`
ffmpeg -h encoder=h264_nvenc
from multiprocessing import Queue | |
from multiprocessing import Process | |
import time | |
import os | |
import numpy as np | |
def put_into_queue(q: Queue): | |
print(f"PID[{os.getpid()}] put_into_queue") |
When running FastAPI
app, all the logs in console are from Uvicorn
and they do not have timestamp and other useful information. As Uvicorn
applies python logging
module, we can override Uvicorn
logging formatter by applying a new logging configuration.
Meanwhile, it's able to unify the your endpoints logging with the Uvicorn
logging by configuring all of them in the config file log_conf.yaml
.
Before overriding:
uvicorn main:app --reload