Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
source /home/project/myenv/bin/activate
cd /home/project/server
PID=$(ps aux | grep 'uvicorn myapp:app' | grep -v grep | awk {'print $2'} | xargs)
if [ "$PID" != "" ]
then
kill -9 $PID
sleep 2
echo "" > nohup.out
echo "Restarting FastAPI server"
import streamlit as st
import aiohttp
import asyncio
async def fetch(session, url):
try:
async with session.get(url) as response:
result = await response.json()
return result
from flask import Flask, request, jsonify
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.image import MIMEImage
from email.mime.application import MIMEApplication
app = Flask(__name__)
def send_test_mail(body):
from fastapi import FastAPI
from fastapi.openapi.utils import get_openapi
import os
app = FastAPI()
lable_lang_mapping = {"Plain JS": "JavaScript", "NodeJS": "JavaScript"}
@app.get("/hello")
async def hello():
from nebula3.gclient.net import ConnectionPool
from nebula3.Config import Config
# define a config
config = Config()
config.max_connection_pool_size = 10
# init connection pool
connection_pool = ConnectionPool()
# if the given servers are ok, return true, else return false
ok = connection_pool.init([('127.0.0.1', 9669)], config)
import xml.etree.ElementTree as ET
import glob
import os
import json
def xml_to_yolo_bbox(bbox, w, h):
# xmin, ymin, xmax, ymax
x_center = ((bbox[2] + bbox[0]) / 2) / w
y_center = ((bbox[3] + bbox[1]) / 2) / h
from typing import List
import queue
from fastapi import FastAPI, WebSocket, WebSocketDisconnect
from fastapi.responses import HTMLResponse
from apscheduler.schedulers.asyncio import AsyncIOScheduler
app = FastAPI()
app.queue_system = queue.Queue()
app.queue_limit = 5
import streamlit as st
import requests
def fetch(session, url):
try:
result = session.get(url)
return result.json()
except Exception:
return {}
import random
import glob
import os
import shutil
def copyfiles(fil, root_dir):
basename = os.path.basename(fil)
filename = os.path.splitext(basename)[0]
<!DOCTYPE html>
<html>
<head>
<title>Example App</title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<style>
table, th, td {