#๐Ÿ”’ i cant run my python file fastAPI

114 messages ยท Page 1 of 1 (latest)

cerulean lintel
cinder galleonBOT
#

@cerulean lintel

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

sturdy oar
#

thats not a python error i dont think

cerulean lintel
#

im trying to learn fastAPI

sturdy oar
#

try doing the same request with curl or the windows equivilant

#

i dont think anything is at :8080

cerulean lintel
#

i cant run my python file fastAPI

sturdy oar
cerulean lintel
#

what should i do

sturdy oar
#

run the server at port 8080

cerulean lintel
#

how do i do that

sturdy oar
#

\:

#

127.0.0.1 is your machine

#

if you are following a guide, it probably wants you to run something on your machine

cerulean lintel
#

im following a youtube tutorial

sturdy oar
#

gimme

cerulean lintel
#

ok

#

Unlock the power of Python APIs with our step-by-step tutorial on FastAPI and OpenAI's ChatGPT. FastAPI is a high-performance web framework that's perfect for building APIs, and ChatGPT brings a layer of artificial intelligence into the mix.

AI Demos: https://www.aidemos.com/

AIDemos.com is your go-to directory for video demos of the latest AI...

โ–ถ Play video
#

im on 13:31

sturdy oar
#

indian bro โœŠ

#

(holdon am watching thru it)

cerulean lintel
#

ok thanks

sturdy oar
#

i recommend using a venv

cerulean lintel
#

i did but i opened a new terminal maybe this is the problem

sturdy oar
#

do pip list

cerulean lintel
#

PS C:\Users\Layan\OneDrive\Desktop\ChatBot\app> pip list
Package Version


annotated-types 0.7.0
anyio 4.8.0
certifi 2025.1.31
charset-normalizer 3.4.1
click 8.1.8
colorama 0.4.6
distro 1.9.0
fastapi 0.115.8
h11 0.14.0
httpcore 1.0.7
httpx 0.28.1
idna 3.10
jiter 0.8.2
openai 1.61.0
pip 25.0
pydantic 2.10.6
pydantic_core 2.27.2
requests 2.32.3
sniffio 1.3.1
starlette 0.45.3
tqdm 4.67.1
typing_extensions 4.12.2
urllib3 2.3.0
uvicorn 0.34.0

sturdy oar
#

that looks right, ill keep watching :)

#

have you got this running in the background

#

(this one has chosen port 8000 not 8080)

cerulean lintel
#

yes

sturdy oar
#

does it say port 8080

cerulean lintel
#

btw i have a diffrenet end poing on my main.py

sturdy oar
#

hmm

#

you have a leading / in @app.post

#

try removing that

cerulean lintel
#

from line 5 to 11

sturdy oar
#

replace line 5 with
@app.post("/chatbot-response")

cerulean lintel
#

ok i did

#

but arent they the same?

sturdy oar
#

things ending in a / are a directory

cerulean lintel
#

ok

sturdy oar
#

idk if it makes a difference, try it

cerulean lintel
#

i did

sturdy oar
#

connection refused suggests that it cant reach the server

#

you sure its runningon 8080

cerulean lintel
#

how do i know

sturdy oar
#

it should say

#

Uvicorn running on http://127.0.0.1:8000

cerulean lintel
#

yes i did this step before and it was running

#

keep watching till he makes a new file called request

#

and run on a new terminal

sturdy oar
cerulean lintel
#

i forgot

sturdy oar
#

x-x

#

(check)

cerulean lintel
#

uvicorn request:app --reload?

sturdy oar
#

its running on poort 8000

#

change in your request file from 8080 -> 8000

cerulean lintel
#

ok done

#

now i can run python ./request?

sturdy oar
#

yeah

#

make sure the server is running tho

cerulean lintel
#

how do i do that

sturdy oar
#

have one terminal which looks like this

#

have another for doing python request

cerulean lintel
#

do i have to change main to request?

sturdy oar
#

im not sure what you mean

#

you have "main" (?) which is the fastapi server (?)

#

and "request" (?) which does a request to it

cerulean lintel
#

bc i have another file called request which im trying to run but its ok i did it on both and the server working

#

but on my other terminal which im trying to do python request on. the terminal is stuck it looks like this

#

i cant write on it

#

i tried control c

#

didnt work

sturdy oar
#

you can close on the right tab

#

idk if that kills the process, you might have to use taskmgr

cerulean lintel
#

UGHHHHHHHHHHHH

sturdy oar
cerulean lintel
#

i closed that terminal and opened a new one and typed python request

#

and got this

sturdy oar
#

im gonna try it

cerulean lintel
#

u want a screenshot?

sturdy oar
#

the files

cerulean lintel
#

there u go

sturdy oar
#

ty

#

works... for me x-x

cerulean lintel
#

u tried running python request?

sturdy oar
#

what i did:

1. put main.py and request.py in a folder
2. python -m venv .venv
3. activate venv
4. pip install fastapi uvicorn requests
5. uvicorn main:app --reload
6. new terminal
7. activate venv
8. python request
9. {'detail': [{'type': 'missing', 'loc': ['query', 'user_message'], 'msg': 'Field required', 'input': None}]}
#

an error message still but it gave me something

cerulean lintel
#

thank u solly

#

appreciate ur help

sturdy oar
#

but it doesnt work for you

#

x-x

cerulean lintel
#

ill cancel my terminals and try do ur steps and let u know

sturdy oar
#

you can try netstat -an | find "8000" (in cmd) to see if the server has actually bound itself to 8000

cerulean lintel
#

when should i try it

sturdy oar
#

after youve run the server and it says "runnin on port 8000"

cinder galleonBOT
#
Python help channel closed for inactivity

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.