Web 服务器仅从 http://localhost:8000 启动
Webserver only launches from http://localhost:8000
我是 运行 这个你好世界的例子:
https://rocket.rs/v0.4/guide/quickstart/#running-examples
$ cargo run
Finished dev [unoptimized + debuginfo] target(s) in 1.32s
Running `C:\Users\m3\repos\Rocket\target\debug\hello_world.exe`
Configured for development.
=> address: localhost
=> port: 8000
=> log: normal
=> workers: 8
=> secret key: generated
=> limits: forms = 32KiB
=> keep-alive: 5s
=> read timeout: 5s
=> write timeout: 5s
=> tls: disabled
Mounting /:
=> GET / (hello)
Rocket has launched from http://localhost:8000
代码可在此处获得:
https://github.com/SergioBenitez/Rocket/tree/v0.4/examples/hello_world
问题
问题是它只能从 http://localhost:8000
启动。它不适用于 http://127.0.0.1:8000
或 http://192.168.1.250:8000
。
问题
如何修改代码使服务器从 127.0.0.1
或服务器的静态 IP 地址启动,即 192.168.1.250
?我检查了代码,但无法弄清楚如何。
没用
修改Cargo.toml
config并添加地址和端口:
[global]
address = "0.0.0.0"
port = 80
快速浏览 documentation 提到一个名为 rocket.toml
的文件
尝试将配置放在名为 Rocket.toml
的文件中
[global]
address = "0.0.0.0"
port = 80
我是 运行 这个你好世界的例子:
https://rocket.rs/v0.4/guide/quickstart/#running-examples
$ cargo run
Finished dev [unoptimized + debuginfo] target(s) in 1.32s
Running `C:\Users\m3\repos\Rocket\target\debug\hello_world.exe`
Configured for development.
=> address: localhost
=> port: 8000
=> log: normal
=> workers: 8
=> secret key: generated
=> limits: forms = 32KiB
=> keep-alive: 5s
=> read timeout: 5s
=> write timeout: 5s
=> tls: disabled
Mounting /:
=> GET / (hello)
Rocket has launched from http://localhost:8000
代码可在此处获得:
https://github.com/SergioBenitez/Rocket/tree/v0.4/examples/hello_world
问题
问题是它只能从 http://localhost:8000
启动。它不适用于 http://127.0.0.1:8000
或 http://192.168.1.250:8000
。
问题
如何修改代码使服务器从 127.0.0.1
或服务器的静态 IP 地址启动,即 192.168.1.250
?我检查了代码,但无法弄清楚如何。
没用
修改Cargo.toml
config并添加地址和端口:
[global]
address = "0.0.0.0"
port = 80
快速浏览 documentation 提到一个名为 rocket.toml
的文件尝试将配置放在名为 Rocket.toml
[global]
address = "0.0.0.0"
port = 80