Exemplo n.º 1
0
async def show_qrscan(request: Request, bgTask:  BackgroundTasks, qrdata: str = Form(...), geocity: str = Form(...)):
    global inputDataQueue, curGeoCity
    print('@qrscan ', qrdata, geocity)
    if qrdata is None:
        return templates.TemplateResponse('getData.html', {"request": request, 'dataQueue': inputDataQueue})
    referrer = request.headers.get("Referer")
    remoteIp = request.client.host
    print('@show_qrscan ',referrer, remoteIp)

    # 입력받는대로 저장한다
    # QR_Str = request.form.get('qrdata')
    QR_Str = qrdata.__str__()
    curGeoCity = getCity(geocity)
    print('@show_qrscan QR_Str ', QR_Str, getCity(geocity))
    timeChecker()

    print('QR scaned: DataType %s  %s'%(type(QR_Str), QR_Str))
    # 적절한 크기로 자른다 - space tab enter 모두 잘라낸다
    # if (' ' in QR_Str ) or ('\t' in QR_Str ) or ('\n' in QR_Str ) or ('\b' in QR_Str):
    #     QRvalueSet = re.split(' |\t|\n',QR_Str)

    if ('|' in QR_Str ) or ('\n' in QR_Str ):
        QRvalueSet = re.split('\||\n',QR_Str)
        for QRvalue in QRvalueSet :
            if (QRvalue == 'NA') or (QRvalue == '') :
                continue
            # await dataProcessing(QRvalue)
            bgTask.add_task(hiddenProcessing,QRvalue)
            # background_tasks.add_task(write_log, QRvalue)
            # background_tasks.add_task(dataProcessing, QRvalue)

            # rawScanData.append(QRvalue)
            # prdData = build_List(QRvalue)
            # productList.append(prdData)
            # DataQueuing(prdData)

            # # saveExcel(prdData)
            # # excelIO.queueData(prdData)
            # # if (prdData[0] != 'NA' and prdData[1] == 'NA' and prdData[2] == 'NA' ) :
            # #     waybillList.append(prdData)
            # print('QRdata_[i]: ', prdData)
    else:
        QRvalue = QR_Str
        # background_tasks.add_task(write_log, QRvalue)
        # background_tasks.add_task(dataProcessing, QRvalue)
        bgTask.add_task(hiddenProcessing, QRvalue)
        # await dataProcessing(QRvalue)

        # rawScanData.append(QRvalue)
        # prdData = build_List(QRvalue)
        # productList.append(prdData)
        # DataQueuing(prdData)

        # # if prdData[0] != 'NA':
        # #     waybillList.append(prdData)
        # # saveExcel(prdData)
        # # excelIO.queueData(prdData)
        # print('QRdata_2: ', prdData)

    print('referrer: ',referrer)
    # referrer = request.headers.get("Referer")
    # return RedirectResponse(referrer)
    # return inputDataQueue
    # return True
    return RedirectResponse(referrer)
Exemplo n.º 2
0
async def http_exception_handler(request: Request, exc):
    '''
    Redirect all 404 traffic to homepage
    '''
    return RedirectResponse('/')
Exemplo n.º 3
0
def index():
    """For local development, serve the index.html in the dist folder

    NOTE: Not needed for vue cli
    """
    return RedirectResponse(url="client/index.html")
Exemplo n.º 4
0
async def main():
    return RedirectResponse(url="/docs/")
Exemplo n.º 5
0
async def home():
    return RedirectResponse("/docs")
Exemplo n.º 6
0
def backtesting(strategy_id: int = Form(...), stock_id: int = Form(...)):

    return RedirectResponse(url=f"/backtesting/{strategy_id}/{stock_id}",
                            status_code=303)
Exemplo n.º 7
0
async def serverredirect():
    return RedirectResponse(url='https://discord.gg/4R72Pks')
Exemplo n.º 8
0
Arquivo: app.py Projeto: b1team/trada
async def root():
    return RedirectResponse("/docs")
Exemplo n.º 9
0
def post_login(username: str = Form(...), password: str = Form(...)):
    if is_valid_user(username, password):
        return "User is valid"
    else:
        return RedirectResponse("/ui/login.html?error",
                                status_code=status.HTTP_302_FOUND)
async def redirect():
    return RedirectResponse("/new-url")
Exemplo n.º 11
0
def logout(request: Request):
    return RedirectResponse('/', status_code=401)
Exemplo n.º 12
0
async def docs_redirect():
    """Api's base route that displays the information created above in the ApiInfo section."""
    return RedirectResponse(url="/docs")
Exemplo n.º 13
0
async def notfound_exception_handler(request, exc):
    """Catch all response, redirect to index. Necessary when using Vue Router"""
    return RedirectResponse(url="/index.html")
Exemplo n.º 14
0
async def index():
    """For local development, serve the index.html in the dist folder"""
    return RedirectResponse(url="/index.html")
Exemplo n.º 15
0
async def root():
    return RedirectResponse(url='/info')
Exemplo n.º 16
0
def auth_exception_handler(request: Request, exc: NotAuthenticatedException):
    """
    Redirect the user to the login page if not logged in
    """
    rslogger.debug("User is not logged in, redirecting")
    return RedirectResponse(url=f"{settings.login_url}")
Exemplo n.º 17
0
 async def index():
     return RedirectResponse("/panel/")
Exemplo n.º 18
0
def authjwt_exception_handler(request: Request, exc: AuthJWTException):
    return RedirectResponse(url="/login")
Exemplo n.º 19
0
async def redirecttodocs():
    return RedirectResponse(url='/redoc')
Exemplo n.º 20
0
async def receive_cards(
        request: Request,
        owner: schema.PlayerType,
        game_id: str,
        flags: int = 0,
        count: int = 1,
        r1: int = Form(None),
        r2: int = Form(None),
        r3: int = Form(None),
        r4: int = Form(None),
        r0: int = Form(None),
        p1: int = Form(None),
        p2: int = Form(None),
        p3: int = Form(None),
        p4: int = Form(None),
        p0: int = Form(None),
        a1: int = Form(None),
        a2: int = Form(None),
        a3: int = Form(None),
        a4: int = Form(None),
        a0: int = Form(None),
        f1: int = Form(None),
        f2: int = Form(None),
        f3: int = Form(None),
        f4: int = Form(None),
        f0: int = Form(None),
):
    game_round = await crud.get_round_by_game_id(game_id)
    if owner == schema.PlayerType.changeling:
        hand = game_round.changeling_hand
    else:
        hand = game_round.child_hand
    # relationships = [x for x in [r1, r2, r3, r4, r5] if x]
    relationships = [
        hand.relationships[n] for n in [r0, r1, r2, r3, r4] if n is not None
    ]
    possessions = [
        hand.possessions[n] for n in [p0, p1, p2, p3, p4] if n is not None
    ]
    actions = [hand.actions[n] for n in [a0, a1, a2, a3, a4] if n is not None]
    feelings = [
        hand.feelings[n] for n in [f0, f1, f2, f3, f4] if n is not None
    ]

    for card_type in [relationships, possessions, actions, feelings]:
        if len(card_type) != count:
            return {
                "message":
                "Invalid choice. Please return to the lobby and try again."
            }
    new_hand = schema.Hand(
        relationships=relationships,
        possessions=possessions,
        actions=actions,
        feelings=feelings,
    )

    aws = [
        crud.update_flags(game_id, schema.GameState(flags)),
        crud.update_hand(game_id, new_hand, owner),
    ]

    await asyncio.gather(*aws)
    return RedirectResponse(url=f"/game/{game_id}",
                            status_code=status.HTTP_303_SEE_OTHER)
Exemplo n.º 21
0
async def home():
    return RedirectResponse("http://sadedegel.ai")
Exemplo n.º 22
0
async def new(request: Request, response: Response) -> Response:
    return RedirectResponse(request.url_for('queue'),
                            headers=dict(response.headers))
Exemplo n.º 23
0
async def http_exception_handler(request, exc):
    return RedirectResponse("/")
Exemplo n.º 24
0
async def root():
    return RedirectResponse('/login')
Exemplo n.º 25
0
async def main():
    return RedirectResponse("/static/index.html")
Exemplo n.º 26
0
async def add_log_record(material_id: UUID = Form(...),
                         count: PositiveInt = Form(...),
                         date: datetime.date = Form(...)):
    await db.set_log(material_id=material_id, count=count, date=date)
    return RedirectResponse('/reading_log/add-view', status_code=302)
Exemplo n.º 27
0
async def read_typer():
    return RedirectResponse("https://typer.tiangolo.com")
Exemplo n.º 28
0
async def _tensorboard():
    """Ensure TensorBoard is running on port 6006
    via `tensorboard --logdir tensorboard`."""
    return RedirectResponse("http://localhost:6006/")
Exemplo n.º 29
0
async def docs():
    return RedirectResponse(url="/docs")
Exemplo n.º 30
0
def upload_story():
    referrer = request.headers.get("Referer")
    return RedirectResponse(referrer)