2 years ago

#75770

test-img

Niewasz Biznes

FastAPI, python, get - pass variable from different function

In file1 (fast_api file):

app = Fast API(title='myapp', docs_url='/', description="some_desc")
app.test = "In file1"

def run_fastapi(context):
    uvicorn.run("api:app", reload=False)

@app.get("/api/some_value", responses=SOME_RESPONSES)
def get_parcels(response: Response):
    test = app.store
    print(test)

then in file2: I want to be able to do:

import file1

if __name__ == "__main__":
    file1.app.store = "In file2"
    file1.app.run_fastapi()

But every time I am getting "in File1", how can i modify my code to be able to change value of app.test inside file2?

python

fastapi

0 Answers

Your Answer

Accepted video resources