我正在运行Flask应用程序,其基本布局为:
def run_period():
urllib2.urlopen('http://10.0.2.15:8080/foo')
@app.route('/')
def mainpage():
run_period()
@app.route('/foo')
def entertainment():
# do something
我的流浪文件配置如下:
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.provision "shell", path: "pg_config.sh"
# config.vm.box = "hashicorp/precise32"
config.vm.box = "ubuntu/trusty32"
config.vm.network "forwarded_port", guest: 8000, host: 8000
config.vm.network "forwarded_port", guest: 8080, host: 8080
config.vm.network "forwarded_port", guest: 5000, host: 5000
end
我在我的虚拟机中执行了ifconfig
以获取我在urlopen()
传递的IP地址。
eth0 Link encap:Ethernet HWaddr 08:00:27:4b:d4:80
inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe4b:d480/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2012 errors:0 dropped:0 overruns:0 frame:0
TX packets:1578 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:219636 (219.6 KB) TX bytes:437048 (437.0 KB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:700 errors:0 dropped:0 overruns:0 frame:0
TX packets:700 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:218049 (218.0 KB) TX bytes:218049 (218.0 KB)
但我无法在我的主机(Windows)机器上打开http://10.0.2.15:8080/
。