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
#!/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" |
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 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 |
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 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): |
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 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(): |
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 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) |
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 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 |
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 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 |
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 streamlit as st | |
import requests | |
def fetch(session, url): | |
try: | |
result = session.get(url) | |
return result.json() | |
except Exception: | |
return {} |
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 random | |
import glob | |
import os | |
import shutil | |
def copyfiles(fil, root_dir): | |
basename = os.path.basename(fil) | |
filename = os.path.splitext(basename)[0] |
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
<!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 { |
NewerOlder