sanic-org / sanic

Accelerate your web app development | Build fast. Run fast.
https://sanic.dev
MIT License
18.03k stars 1.55k forks source link

Always use Default Host and Port #2653

Closed Spiffy1 closed 1 year ago

Spiffy1 commented 1 year ago

Is there an existing issue for this?

Describe the bug

The image should be self explanatory, however in case it doesn't work. I wants to use port 8080 on app.run(port=8080). However, when I run sanic main:app, it always shows that it publish to port 8000. And it only works on port 8000. I can not use any port other than 8000. image

The bug is also found on host. If I want to use local host or 0.0.0.0, it doesn't work.

Code snippet

No response

Expected Behavior

I expect that when the port is declared on app.run to be 8080, then it should be http://127.0.0.1:8080/ not http://127.0.0.1:8000/

When I set the host to 0.0.0.0 or localhost, I should be able to use that to test my webserver. For example: 0.0.0.0:8000 or localhost:8000.

How do you run Sanic?

Sanic CLI

Operating System

Windows and Ubuntu

Sanic Version

latest

Additional context

No response

ahopkins commented 1 year ago

This is not a bug. You should be using the CLI or app.run. Not both. When using the CLI nothing I'm the "if main" block runs. When using the cli, there are flags and options to control host and port. 😎

Spiffy1 commented 1 year ago

Thank you for your quick response.