端口上的Vagrant和bottlepy错误

时间:2015-08-16 19:08:36

标签: python vagrant port bottle

我有这个流浪文件......

# -*- mode: ruby -*-
# vi: set ft=ruby :

# Config Github Settings
github_username = "fideloper"
github_repo     = "Vaprobash"
github_branch   = "1.4.0"
github_url      = "https://raw.githubusercontent.com/#  {github_username}/#{github_repo}/#{github_branch}"

# Server Configuration
hostname        = "m101p"

server_ip             = "192.168.0.127"
server_cpus           = "1"   # Cores
server_memory         = "384" # MB
server_swap           = "768" # Options: false | int (MB) - Guideline: Between one or two times the server_memory

server_timezone       = "UTC"
public_folder         = "/vagrant"

Vagrant.configure("2") do |config|

    # Set server to Ubuntu 14.04
    config.vm.box = "ubuntu/trusty64"

    config.vm.define "M101P" do |vapro|
    end

    # Create a hostname, don't forget to put it to the `hosts` file
    # This will point to the server's default virtual host
    # TO DO: Make this work with virtualhost along-side xip.io URL
    config.vm.hostname = hostname

    # Create a static IP
    config.vm.network :public_network, ip: server_ip
    config.vm.network :forwarded_port, guest: 8000, host: 8001

    config.ssh.forward_agent = true

    config.vm.synced_folder ".", "/vagrant"

    config.vm.provider :virtualbox do |vb|

    vb.name = "M101P"

    vb.customize ["modifyvm", :id, "--cpus", server_cpus]

    vb.customize ["modifyvm", :id, "--memory", server_memory]

    vb.customize ["guestproperty", "set", :id, "/VirtualBox/GuestAdd/VBoxService/--timesync-set-threshold", 10000]

    end

    ####
    # Base Items
    ##########

    # Provision Base Packages
    config.vm.provision "shell", path: "#{github_url}/scripts/base.sh", args: [github_url, server_swap, server_timezone]

    # optimize base box
    config.vm.provision "shell", path: "#{github_url}/scripts/base_box_optimizations.sh", privileged: true

    # Provision Bottle FrameWork
    config.vm.provision "shell", path: "./bottlepy.sh"
    enter code here

end

这条规定:

  

bottlepy.sh

#!/usr/bin/env bash
echo ">>> Python-Bottle"
echo ">>> Requierements Python-Bottle"
apt-get install -qq build-essential python python-dev python-setuptools python-pip
echo ">>> Install Python-Bottle"
pip install bottle

运行这个流浪汉机器后,我有测试瓶的代码

from bottle import route, run

@route('/')
@route('/hello/<name>')
def greet(name='Stranger'):
    return 'Hello %s, how are you?'%name

run(host='localhost', port=8000, debug=True)

但是当我跑...:

  

vagrant @ m101p:/ vagrant $ python test.py

     

启动Bottle v0.12.8服务器(使用WSGIRefServer())...

     

聆听http://localhost:8000/

     

按Ctrl-C退出。

当我从网络浏览器托盘访问时..只能得到这个..

请某人帮助我......需要测试一下......

0 个答案:

没有答案