Using subdomains in Play framework 1.2.7 - playframework-1.x

I want to use subdomains in Play Framework 1.2.7
I have a routes file like so
GET platform.mydomain.com.au/ Application.platform
But I get a 404 when I try to navigate to the page. I would expect to at least get a Play specific error if something was wrong with the routes file.
I've seen evidence that it should be possible to use subdomains e.g.
Here:
http://www.playframework.com/documentation/1.2.7/configuration
https://groups.google.com/forum/#!topic/play-framework/bclX-ZmXDcU
But nothing explicitly says it can/can't be done and if it can be done, how to do it.

Related

How to use react build websites without using react-router ?

I'm building a website with Django and react, and since Django itself has a routing system, and I don't want to discard that, so I decide not to use javascript routing libraries.
I'm using webpack to bundle my files, but since I'm not using react router, there's a lot of webpack entry files, and a lot of bundled files (almost one per page), and I'm not sure if this is a 'correct' way.
And since there's one javascript file per page, the states or other things between different pages are not shared, every page is independent of each other. Can I have some 'shared' things without using react-router?
I know Facebook itself and Airbnb don't use react-router either, so how do they use react? How do they handle a lot of bundled files?
Can anyone work for a company that does not use react-router share your company's solutions?
The proper way to accomplish this is in the same way as you do it using vanilla javascript or some library like jQuery.
You don't manage a state in the front end, you grab the state server side and you put it in the HTML and then you use it with javascript.
React.js isn't different and if you're using redux you could put that data directly in the initial state of every page/section of your whole webpage.
<>
Yes. But in order to share in the way you imagine, you do have to make your app single paged. That is, you don't link around to different URL's. Any view change would change at most the #anchor part of the URL, but needn't do anything to the URL - just use Javascript logic to change what component(s) get rendered. As long as the base part of your URL stays on the same page, your shared objects will stick around.

static site pagination with google app engine

I have an octopress/jekyll blog that I am trying to host with Google App Engine. Here's a different SO question that got me started: How to Regex for static webpage on Google App Engine?
However, I would ALSO like to get pretty urls working (with no index.html required at the end of the url).
e.g. /blog/post/ instead of /blog/post/index.html
For some of this I can wire up explicit rules (though it's pretty ugly). For the pagination pages (/blog/page2 for example) there is no way to know how many there will be and therefore can't wire them up.
I dimly suspect this will require a python script, but I'm wondering if there might be some regex magic that would accomplish the same thing? Either way, anyone have an idea? An example of a script that might work?

Running Django in a "mixed" directory

Is there a straightforward way to set up Django to operate on a directory or set of directories that will also serve other kinds of content?
Right now I have a webserver that is mostly running ColdFusion pages, but I'd like to start moving some sections over to Django. However, due to the existing directory structure it's not ideal to put all of the Django stuff in just one web path. Ideally I'd like to be able to keep using the original directory structure rather than having to use a lot of redirects.
Is there any way to make Django play nice with other things, or does it pretty much need its own root to be happy? The only other solution I can think of is carefully configuring the web server with a lot of rules that purposefully sidestep Django when necessary (for example, instructing it to manually handle anything with a file extension, or to ignore certain directories).
This would be on IIS, if it happened.
You can configure URLs in Django anyway you like. Have a look at the URL dispatcher. So say for instance your site www.example.com, you decide to have /wiki and /blog be developed using Django. You can configure IIS to redirect those urls to Django, while the rest of www.example.com/everythingelse is served by Coldfusion or whatever.
Even a mixed url scheme say /store/mycoldfusion-product-view and /store/django-product-view would be possible though this would require some amount of fancy redirect code depending on your setup.
It sounds as if you have some control over what is being served when. If that's the case, could you use a reverse proxy to segment your namespace? I do this with a lot of different projects; I use nginx, and tell it "these paths are for Wordpress, these paths are for Django, and these paths are for images and other static content."
That's an excellent way of making Django "play nice," as long as you have a disciplined approach to converting some of the paths to one or the other.
An alternative way to set this up would be to daisy chain:
Webserver -> django -> response middleware -> subprocess/pipe/httplib -> coldfusion.
The response middleware would pseudo code something like this:
if response.code in [list of ok responses]:
return
else:
call coldfusion
The advantage of this method would be that you can transition at whatever rate you want. The disadvantage is that it isn't a simple configuration, daisy chains are brittle by nature, and the daisy chain might break.

How can I write a route/view/controller for a web framework which acts as a dumb proxy?

That is to say, let's say I'm writing something that's hosted on foo.com. I'd like it to be possible for a user who goes to foo.com/bar.com to be served up bar.com from foo.com and to be able to interact with bar.com (e.g. navigate to foo.com/bar.com/baz via point-and-click). I understand that this is what a proxy is supposed to do. I need to do some preprocessing of a request to access the proxy, which is why I'm turning to a web framework. I've a preference for django, rails, or sinatra, or another python/ruby solution, but any will do, really.
Thanks in advance; alternate suggestions are welcome.
First you will need to parse the URL at foo.com. In django you could have an url like this(not tested):
url(r'(?P<url>.*)$', my_proxy_view, name = 'proxy')
So http://foo.com/bar.com/baz/ will give you an url of 'bar.com/baz/' you may use as you please in your view.
Then you have to retrieve the page at bar.com, using a library like urllib2.
When you have the contents of the remote page, you need to change all links(anchor elements) that point to bar.com to point to the URLs of your proxy. If you want to proxy images, stylesheets and javascript you need to change the links of those as well.
You probably want to cache as much as possible as well. And be sure to set a user-agent on the urllib request that will let the other site know that this is some kind of robot or proxy.
With that said, this sounds like a really stupid idea. What is your use case?
i can only talk about django, but....
if you only want to use the same object/data on multiple websites you should have a look at the django sites framework
for redirects i would suggest the redirects app
or you simply use the redirect shortcut in your views

Django, from php to Django

I have a website done with Django, that was previously done with PHP and CodeIgniter. I've moved the website to Webfaction, changed the DNS and all other configurations, but now my email is full of errors like this:
Error (EXTERNAL IP): /index.php/main/leer/7497
I don't know why the Django app is looking for pages from the PHP app, specially since the PHP app was in another host.
Are those URLs from your old site? That's probably a case of people having stale bookmarks, trying to navigate to them, and getting 404s. You might want to consider catching those, and redirecting to the new URL with response code 302.
I can't imagine those errors are caused by Django (except in the sense that the reports are from Django reporting 404s, which it does for free).
I agree with above. Just want to add you should use django.contrib.redirects to move the redirects.
You can read more about it here