This repository was archived by the owner on Aug 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
executable file
·61 lines (29 loc) · 1.92 KB
/
Copy pathapp.py
File metadata and controls
executable file
·61 lines (29 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# coding: utf-8
'''
Codded By :
█ █░ ██▓ ██▓ ▓█████▄ ▒█████ ███▄ █ ██▓ ▒█████ ███▄ █
▓█░ █ ░█░▓██▒▓██▒ ▒██▀ ██▌▒██▒ ██▒ ██ ▀█ █ ▓██▒▒██▒ ██▒ ██ ▀█ █
▒█░ █ ░█ ▒██▒▒██░ ░██ █▌▒██░ ██▒▓██ ▀█ ██▒▒██▒▒██░ ██▒▓██ ▀█ ██▒
░█░ █ ░█ ░██░▒██░ ░▓█▄ ▌▒██ ██░▓██▒ ▐▌██▒░██░▒██ ██░▓██▒ ▐▌██▒
░░██▒██▓ ░██░░██████▒░▒████▓ ░ ████▓▒░▒██░ ▓██░░██░░ ████▓▒░▒██░ ▓██
'''
import os
import sys
# typer doesn't know the path of imported module in where it's imported like in here
# to solve this we have to give typer the full path of a module that we want to import it in its main file(app.py).
# it's like typer has its own namespace for running functions decorated with app.command()
# this file will import in typer main file and you can see the bytecode of this file in __pycache__ folder.
configfile = 'controller.py'
path = sys.path.append(os.path.dirname(os.path.expanduser(configfile)))
import uvicorn
import typer
import multiprocessing
from controller import app
from piper import DatasetStreamer
from piper import api
@app.command()
def develop(workers: int = typer.Option(multiprocessing.cpu_count(), help="Number of workers.", min=4)):
typer.secho("\n________Running in development________\n", fg=typer.colors.MAGENTA, bold=True)
uvicorn.run('app:api', host="api.unixerr.com", port=8000, reload=True, workers=workers, lifespan="on")
if __name__ == "__main__":
app()