Hello World in Django involves 4 Python files, whose relationships I'm not
100% clear on, so I haven't written an example for it. But this
framework-less web server works, so I don't see why Django wouldn't
using PyCall
@pyimport textwrap
@pyimport BaseHTTPServer as HS
@pydef type HelloRequestHandler <: HS.BaseHTTPRequestHandler
do_GET(self) = begin
if self[:path] != "/"
self[:send_error](404, "Object is not found")
return
end
self[:send_response](200)
self[:send_header]("Content-type", "text/html; charset=utf-8")
self[:end_headers]()
response_text = """
<html>
<head>
<title>Greetings to the world</title>
</head>
<body>
<h1>Greetings to the world</h1>
<p>Hello, world!</p>
</body>
</html>
"""
self[:wfile][:write](response_text)
end
end
server_address = ("", 8000)
httpd = HS.HTTPServer(server_address, HelloRequestHandler)
httpd[:serve_forever]()
# go to localhost:8000
On Tuesday, April 12, 2016 at 7:05:49 AM UTC-4, Páll Haraldsson wrote:
>
> On Friday, April 8, 2016 at 8:59:33 PM UTC, Steven G. Johnson wrote:
>>
>> Just FYI, cstjean has implemented a really cool new feature in PyCall (
>> https://github.com/stevengj/PyCall.jl/pull/250 ... requires PyCall
>> master at the moment): you can now define new Python classes easily from
>> Julia, via a natural syntax:
>>
>
>
>> Multiple inheritance, special methods like __init__, and getter/setter
>> properties are all supported. Better yet, the methods support full Julian
>> multiple dispatch, optional args, and keywords (because, at their core,
>> they are ordinary Julia functions with ordinary dispatch taking place after
>> the Python arguments are converted to Julia types).
>>
>> It will be interesting to see what new kinds of interoperability this
>> enables. (I suspect that Python GUI toolkits, which often require you to
>> define your own classes, will become much easier to use.)
>>
>
> One thing I can think of, enabling using Django with Julia:
>
> https://docs.djangoproject.com/en/1.9/topics/class-based-views/intro/
>
> https://docs.djangoproject.com/es/1.9/topics/db/models/
>
>
> As I expected, the [GUI/web] framework Hollywood principle ("Don't call
> us. We'll call you"), seem to apply to Django too.
>
> As I've never used Django, and more generally do not have a complete
> overview of Python, would you say most any library and now framework of
> Python is supported with PyCall? At least the language features required by
> Django?
>
> [Is Django, preferable over web micro-frameworks, such as the Sinatra-like
> native Julia one? Or some other code, such as http://escher-jl.org/ ? I
> just like to know Django, and all Python web stuff is available.. Might
> look into all ways.]
>
> --
> Palli.
>
>