librelist archives

« back to archive

Testing subdomains locally

Testing subdomains locally

From:
Adam Markham
Date:
2013-03-28 @ 13:38
Hi,

I have a bunch of subdomains in my hosts file like:

127.0.0.1       adam.local
127.0.0.1       eggs.adam.local
127.0.0.1       me.adam.local

Trouble is I have to manually edit these every time I add a new
subdomain. I also want to dynamically generate subdomains where they
can not be added to hosts file in advance for local testing.

The code I currently have is:

app = Flask(__name__)

app.config['SERVER_NAME'] = 'adam.local:5000'

@app.route("/", subdomain="eggs")
def egg_index():
    return "You have eggs"

@app.route("/", subdomain="me")
def egg_index():
    return "You have me"

@app.route("/")
def index():
    return "This is the index"

if __name__ == "__main__":
    app.run()

Is there a solution for this problem?

Thanks,

Adam

Re: [flask] Testing subdomains locally

From:
Markus Unterwaditzer
Date:
2013-03-28 @ 13:45
Adam Markham <adamjmarkham@gmail.com> wrote:

>Hi,
>
>I have a bunch of subdomains in my hosts file like:
>
>127.0.0.1       adam.local
>127.0.0.1       eggs.adam.local
>127.0.0.1       me.adam.local
>
>Trouble is I have to manually edit these every time I add a new
>subdomain. I also want to dynamically generate subdomains where they
>can not be added to hosts file in advance for local testing.
>
>The code I currently have is:
>
>app = Flask(__name__)
>
>app.config['SERVER_NAME'] = 'adam.local:5000'
>
>@app.route("/", subdomain="eggs")
>def egg_index():
>    return "You have eggs"
>
>@app.route("/", subdomain="me")
>def egg_index():
>    return "You have me"
>
>@app.route("/")
>def index():
>    return "This is the index"
>
>if __name__ == "__main__":
>    app.run()
>
>Is there a solution for this problem?
>
>Thanks,
>
>Adam

Check out http://xip.io

-- Markus (from phone)

Re: [flask] Testing subdomains locally

From:
Steven Kryskalla
Date:
2013-03-28 @ 16:31
On Thu, Mar 28, 2013 at 6:45 AM, Markus Unterwaditzer
<markus@unterwaditzer.net> wrote:
>
> Check out http://xip.io
>

lvh.me is another alternative.

Re: [flask] Testing subdomains locally

From:
Adam Markham
Date:
2013-03-28 @ 14:09
Working great now. Thanks!

Adam

On Thu, Mar 28, 2013 at 1:45 PM, Markus Unterwaditzer
<markus@unterwaditzer.net> wrote:
> Adam Markham <adamjmarkham@gmail.com> wrote:
>
>>Hi,
>>
>>I have a bunch of subdomains in my hosts file like:
>>
>>127.0.0.1       adam.local
>>127.0.0.1       eggs.adam.local
>>127.0.0.1       me.adam.local
>>
>>Trouble is I have to manually edit these every time I add a new
>>subdomain. I also want to dynamically generate subdomains where they
>>can not be added to hosts file in advance for local testing.
>>
>>The code I currently have is:
>>
>>app = Flask(__name__)
>>
>>app.config['SERVER_NAME'] = 'adam.local:5000'
>>
>>@app.route("/", subdomain="eggs")
>>def egg_index():
>>    return "You have eggs"
>>
>>@app.route("/", subdomain="me")
>>def egg_index():
>>    return "You have me"
>>
>>@app.route("/")
>>def index():
>>    return "This is the index"
>>
>>if __name__ == "__main__":
>>    app.run()
>>
>>Is there a solution for this problem?
>>
>>Thanks,
>>
>>Adam
>
> Check out http://xip.io
>
> -- Markus (from phone)



-- 
AJM