bam bam bhole! how, endpoint accessing on mobile browser i.e chrome LOCALLY using IP Address and PORT beacuse simple *Python* python - m http.server accessible using having port 8000 accessible on mobile After Setting windows defender Inbound rule And allow app and feature defender setting but How FastAPI to access endpoint on mobile browser #11537
-
First Check
Commit to Help
Example Codeorigins = [
"http://127.0.0.1:5500",
"http://localhost:8080",
"http://localhost:5500",
"http://127.0.0.1:5501",
# even i put this addres
"http://computerIpAddr:5501",
"mobileIpAddre:8000"
]
app.add_middleware(
CORSMiddleware,
allow_origins=origins,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# all requirement is imported AND all thing is work on computer but not on other machine like mobile phone browser
app = FastAPI()
@app.get("/bhola")
async def bholaBhola(prabhu: str= "bhola"):
with open(f"{prabhu}Links.txt", "r") if os.path.exists(f'{prabhu}Links.txt') else open("sambhuLinks.txt", "r") as bhola:
bholebaba = bhola.read().split(" ")
return secrets.choice(bholebaba) Descriptionhow, endpoint accessing on mobile browser i.e chrome LOCALLY using IP Address and PORT beacuse simple Python python - m http.server accessible using having port 8000 accessible on mobile After Setting windows defender Inbound rule And allow app and feature defender setting but How FastAPI to access endpoint on mobile browser Acctually happing is that => i make a frontend => html and using javascript to fetch this enpoint and it work on computer but on mobile html and javascript work but FastAPI endpoint are not work Operating SystemWindows Operating System DetailsNo response FastAPI Version0.104.1 Pydantic Version2.4.2 Python Version3.12.1 Additional Contextno I used the GitHub search to find a similar question and didn't find it. * mean => i don't get any solution of that but i Get A |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Some quick things we can do to debug and run in dev environment:
|
Beta Was this translation helpful? Give feedback.
bam bam bhole! thankyou it work after setting host 0.0.0.0 and it run on mobile browser
but before it, it run on HOST 127.0.0.1 and PORT 8000 then why it not work
but a newThing is happenning that Endpoint is being accessing on mobile browser, mean fastapi api run on mobile BUT
when fetch in javascript only host 127.0.0.1 work rather then 0.0.0.0 and fixed 127 1st segment then changes 3 segment of dot number it also work i.e 127.10.0.1, 127.12.0.5, 127.0.10.5 so on
But running html, css , and js file on liveserver and access on mobile browser using computer IP Address and PORT 5501(live server host port) frontend work but FastAPI endpoint fetch not work using js
Question Solution is solved: