def spectrograph(file: bytes = File(...), x: int = Form(...), y: int = Form(...), z: int = Form(...), label=Form(...), window=Form(...), type=Form(...)): key = str(uuid.uuid4()) req = SpectrographRequest(x, y, z, label, window, type) if not req.valid(): return { "err": "Invalid request" } p = Popen( ["sox", "-t", type, "-", "-n", "remix", "1", "spectrogram", "-t", label, "-x", str(x), "-y", str(y), "-z", str(z), "-w", window, "-o", "-"], stdin=PIPE, stdout=PIPE, stderr=PIPE, ) p.stdin.write(file) p.stdin.close() out = p.stdout.read() rdb.set("toolbox:data:" + key, out, ex=TTL) return { "key": key }
def login(request: Request, username: str = Form(...), password: str = Form(...)): print('用户的输入为:') print('username', username) print("password", password) res = YZF_mysql_pyserver.yzf_user().select_Database(username=username) if res != 0: for Item in res: if Item.password == password: vedio_list = YZF_vedio.vedio().vedio_list() return templates.TemplateResponse( "/main.html", { 'request': request, 'username': username, 'vedio_list': vedio_list }) print("登录错误!") return templates.TemplateResponse("/index.html", { 'request': request, 'error': '用户名或密码错误' }) else: print("登录错误!") return templates.TemplateResponse("/index.html", { 'request': request, 'error': '用户名或密码错误' })
def subscribe(request: Request, email: str = Form(...), state: int = Form(...), district_id: int = Form(...), DB: Session = Depends(get_db)): respDict = {} try: subscriber = Subscriber(email=email, state_id=state, district_id=district_id, active=True) create_subscriber(DB, subscriber=subscriber) respDict = { 'request': request, 'isSubscriptionSuccess': True, } return RedirectResponse(url='/subscription/success', status_code=HTTP_302_FOUND) except Exception as inst: status_code = 500 respDict = { 'request': request, 'isSubscriptionSuccess': False, 'error_message': inst } return templates.TemplateResponse('home.html', respDict, status_code=status_code)
async def login(request: Request, username: str = Form(...), password: str = Form(...)): print(f'用户名是{username},密码是{password}') return template.TemplateResponse('index.html', { 'request': request, 'username': username })
async def post_revoke_token( request: Request, token: str = Form(...), token_type_hint: Optional[TypeHint] = Form(None), ): """Revokes a token.""" response: Response = await token_revocation.create_response( token, token_type_hint, request=await oauth2_request(request), ) allow_all_post_cors.augment(request, response) return response
async def tokenize(sentence_list: str = Form( ..., description= r'Sentence list for CKIP tagging, split multiple sentences by linebreak(`\n`)', example= '美國參議院針對今天總統布希所提名的勞工部長趙小蘭展開認可聽證會,預料她將會很順利通過參議院支持,成為該國有史以來第一位的華裔女性內閣成員。')): global ws, pos, ner sentence_list = sentence_list.split('\n') word_sentence_list = ws(sentence_list) pos_sentence_list = pos(word_sentence_list) entity_sentence_list = ner(word_sentence_list, pos_sentence_list) # Show results result = [] def print_word_pos_sentence(word_sentence, pos_sentence): assert len(word_sentence) == len(pos_sentence) word_pos_sentence = "" for word, pos in zip(word_sentence, pos_sentence): word_pos_sentence += f"{word}({pos})" + "\u3000" return word_pos_sentence for i in range(len(sentence_list)): result.append( print_word_pos_sentence(word_sentence_list[i], pos_sentence_list[i])) for entity in sorted(entity_sentence_list[i]): result.append(str(entity)) result.append("") return '\n'.join(result)
async def create_upload_file( request: Request, files: List[UploadFile] = File(...), username: str = Form(...), ): ''' 返回成功上传的文件名列表 ''' vedio_list = YZF_vedio.vedio().vedio_list() for item in files: contents = await item.read() # 检测文件类型是否为MP4格式 if item.content_type == "video/mp4": file_link = "./static/vedio/" + str(item.filename) with open(file_link, 'wb') as f: f.write(contents) else: # 返回0表示错误 return templates.TemplateResponse( "/main.html", { 'request': request, 'username': username, 'filenames': '上传文件类型并非MP4文件!', 'vedio_list': vedio_list }) return templates.TemplateResponse( "/main.html", { 'request': request, "filenames": [file.filename for file in files], 'username': username, "content_type": [file.content_type for file in files], 'vedio_list': vedio_list })
async def send(path: str = Form(...)): logger.info('File send') file_path = make_file_path(path) if os.path.isfile(file_path): return FileResponse(file_path) else: raise IntegrityError()
def post_token(request_data: OAuth2PasswordRequestForm = Form(...)): print(request_data) data = request_data.parse() print(data) print(request_data()) access_token = request_data.username + ":" + request_data.password return {"access_token": access_token}
async def uploadyzf( request: Request, username: str = Form(...), ): return templates.TemplateResponse('/uploadFile.html', { 'request': request, 'username': username, })
async def create_replica(path: str = Form(...), file: UploadFile = FileForm(...)): file_path = make_file_path(path) folder_path = make_dirs_path(path) if not os.path.isfile(file_path): create(file_path, folder_path, file) await report(path) check_file(path, file_path, folder_path) return Status.default() else: raise IntegrityError
async def fileStat2(request: Request, file: bytes = File(...), fileb: UploadFile = File(...), note: str = Form(...)): return templates.TemplateResponse( 'fileStat2.html', { 'request': request, 'fileSize': len(file), 'fileName': fileb.filename, 'note': fileb.content_type })
async def create_file(path: str = Form(...), file: UploadFile = FileForm(...)): file_path = make_file_path(path) folder_path = make_dirs_path(path) logger.info(f'Create file {file_path}') if not os.path.isfile(file_path): create(file_path, folder_path, file) await report(path) if check_file(path, file_path, folder_path): storages = query_storage(srv.id, path) replica(file_path, path, storages) return Status.default() else: raise IntegrityError()
async def create_upload_files(file: UploadFile = File(...), filemd5: str = Form(...)): y = Path("./.temp/" + file.filename) z = Path("./.serve/" + filemd5) #md5 = md5sum(y) if handleUpload.save_upload_file(file, y) is True: shutil.move(y, z) with engine.connect() as conn: conn.execute( text(f""" INSERT INTO TEST1 (FILENAME, DIRECTORY, MD5, VERSION, MESSAGE, UPLOADER) VALUES ('{file.filename}', 'serve', '{filemd5}', {0}, 'first commit', 'billy'); """)) print("done commiting") return {"filenames": file.filename}
def __init__( self, grant_type: Optional[str] = Form(None), code: Optional[str] = Form(None), redirect_uri: Optional[str] = Form(None), client_id: Optional[str] = Form(None), client_secret: Optional[str] = Form(None), code_verifier: Optional[str] = Form(None), username: Optional[str] = Form(None), password: Optional[str] = Form(None), ): self.grant_type = grant_type self.code = code self.redirect_uri = redirect_uri self.client_id = client_id self.client_secret = client_secret self.code_verifier = code_verifier self.username = username self.password = password
def __init__( self, grant_type: str = Form(None, regex="password"), username: str = Form(...), password: str = Form(...), scope: str = Form(""), client_id: Optional[str] = Form(None), client_secret: Optional[str] = Form(None), ): self.grant_type = grant_type self.username = username self.password = password self.scopes = scope.split() self.client_id = client_id self.client_secret = client_secret
def __init__( self, grant_type: str = Form(..., regex="password"), username: str = Form(...), password: str = Form(...), scope: str = Form(""), client_id: Optional[str] = Form(None), client_secret: Optional[str] = Form(None), ): super().__init__( grant_type=grant_type, username=username, password=password, scope=scope, client_id=client_id, client_secret=client_secret, )
def login(username: str = Form("userName"), password: str = Form("passWord")): return {"userName": username, "passWord": password}