Recommend a Python Web Framework

Hello,
Can you guys recommend a python web framework to build a lightweight online chat application? I would like the framework to be light, fast and secure. Preferably free (as in rms free) or at least open-source. In terms of DB functionality I may not use a database at all, but if I do it will be very minimalistic - there will be no chat history, but I am considering user accounts.

Thanks.

Twisted is your best bet.

http://twistedmatrix.com/trac/

You could probably build this in 100 lines or less of code.

1 Like

Of course, you have Django, perhaps the most well known python web framework - although I’m not too big a fan.

I have to say that Tornado looks very appealing.
I would also recommend taking a look at Socket.IO, if you haven’t already - you may want to use SocketTornad.IO which I found from a quick search (so you may want to do more research on Socket.IO + Tornado)

1 Like

I would heavily recommend Flask, as its a python micro-framework that is great for small DIY projects or SPA’s.

Check out this vid to learn more.

1 Like

Seems like it’s a pretty old framework, optimized for Python 2. Are you sure it’s a good idea for Python 3.6?

According to the video from @Dynamic_Gravity Django looks like it comes with too much stuff and has a steep learning curve which is unnecessary for building small and minimalistic applications. Is this why you dislike Django?

Tornado looks like it’s optimized for speed, but it claims to scale well up to tens of thousands of simultaneous connections. So if you have a million users online at the same time then how would it handle them?
Plus it’s the slow-ish on some of the tests here: https://klen.github.io/py-frameworks-bench/

Flask seems quite interesting, but is it open-source? Wiki says nothing about that.
Another thing which surprised me is that it’s not particularly fast even though it’s quite minimalistic:
https://klen.github.io/py-frameworks-bench/

Why isn’t it faster?

Thanks.

Yes its open source, the source for it is on github. Just search for it.

And for the record, i don’t dislike django. Its just not the best tool for minimalist applications.

And define fast? If you do the onlilne tutorial for the micro blog that thing runs pretty snappy. Its probably not the fastest out there. but its a good combination of simplicity and speed.

1 Like

Any thoughts on Sanic?

Question, what are you trying to do that demands such insane performance?

I am just enthusiastic about performance. Why not go as fast as possible?
Trying to build a great product. Sanic seems to be inspired by Flask so I am thinking about learning Flask first and then Sanic.

The reason I say stick with flask, is the amount of documentation and extra packages that you have available. Its basically as big as django, but more beginner friendly. The hello world example takes 5 lines of code to get a server with routing started.

Also, you don’t use python for performance. IF you want something like that you need to look at webassembly.

Isn’t webassembly for client-side scripting?

No.

Webassembly you can interact with compiled C programs on the server, and interact with it from the client through javascript.

That said you can also get some Rust stuff to work. But they’re still working on it.

1 Like

I recently made a webapplication using flask and socket.io on my homeserver and I would definitly recommend it! Using it to access realtime server stats…

1 Like

Socket.IO seems interesting as well.

I can’t recommend flask enough. You only install what you need and they have plugins for everything you could imagine. Very nice to work with.

I found this blog really helpful when using flask.

https://blog.miguelgrinberg.com/

1 Like

I use it in 3.5. Almost all of it is compatible with python 3.

https://twistedmatrix.com/trac/milestone/Python-3.x

I do have to admit, Flask or Django are probably better suited for your use case though. The huge benefit of Twisted is the protocol development aids and the perspective broker. (things that are only needed if you’re building a client and server in python)

1 Like

If I can build a decent GUI without JS I’d prefer no JS. I hate JS.

1 Like

If you’re working in browser, JS is an inevitability.

Ain’t that the sad truth…

1 Like

This is a completely terrible idea, but because you hate JS so much: https://github.com/skulpt/skulpt

1 Like