I've made a small python script to scrap the web. I would like to make a nice and simple web interface where the user can enter data to search for and have the result displayed as a list.
I understand that there's many different ways to do that but don't know which one would be the best in my case.
I would like something :
Really simple and light
Running locally with the less dependencies possible.
So far I've thinking about :
A NodeJS server displaying content and executing the script
A web framework in Python (web.py, Flask, Django..?)
A local webserver (XAMPP) and cgi
Please note that I don't know much about web in python but I'm a bit used to NodeJS.
What would you recommend ?
Thanks, Victor
Personally I prefer gevent, bottle or Flask, and some front end framework like bootstrap or framework7.
Gevent easily makes it asynchronous and has websockets built right in, and bottle is the easiest (and fastest) way to build a web app or api.
Socket.io ist Very easy to send Data between Websites and scripts.
The Website Connect with the Socket.io Server and Inside the Server the Python Script can be executed
Related
I would like to run a couple of very simple Python 3 scripts on the web. As an example, say, the script just reads certain parameters from the URL, sends an email and prints out a simple HTML page saying "success".
I have a virtual private server with Nginx, so I am free to setup the best framework.
My question is: what is the state-of-the-art setup to do this?
More particularly: what do I need to install on my server for Nginx and what do I use in my Python scripts for e.g. reading the URL content? My idea is, that once the server setup is done, I can just put any new script_xy.py file into some directory and it can be accessed using the URL of the script, without a full blown deployment for each script.
Flask If I were to use Flask (or Django), each new script would need its own, continuously running process and its own Nginx setup. That seems like a total overkill to me. Another alternative is web2py, is it the same here or would that be an idea?
CGI 20 years ago I used to program such simple things as Perl scripts using CGI. I read this can be done in principle with Python, but CGI is slow. Then there is Fast CGI. However, my impression was that this is still a bit outdated?
WSGI WSGI seems to be the state-of-the-art alternative to CGI for Python. What python modules would I need to import in my script and what would be the setup for Nginx?
Something else? As you see, I might just need a few hints on what to search for. I am not even sure if I need to search for "Python web framework" or "Python server" etc.
Any help is greatly appreciated.
Thanks a lot for your ideas!
juxeku
I know it's a bit absurd to ask, but can I avoid using web frameworks like - Flask, Falcon, etc and run bare-minimal WSGI server in an nginx environment. I am trying to run my WSGI process in a tight and highly-resource-constrained environment - something like Raspberry Pi. I will not be requiring to handle much of the client load. The number of clients will be 1 or 2 at max. No more than 10 queries per second. So just wondering if I can knock out every component possible by writing some Python code myself.
I have been searching for any documentation on this, but couldn't get much info. Any pointers or suggestions to serve custom python web application without a full-fledged framework is welcome. Last resort would be to understand falcon source code and write a minimal API code myself, which I have already started.
I've been trying websocket-client and socketio-client with no luck so far. The broad picture of what I want to accomplish is this:
Currently, I have a Flask Rest API that has both a web front-end and a command line interface, and it handles several different sets of file uploads/downloads. Both communicate with the server using HTTP requests, the web one from JQuery AJAX and the CLI uses python requests. I would like to switch to using sockets so that database changes from one client appear on all of them. I have been able to get Flask-SocketIO working between my JQuery and Flask server, but I'm struggling with getting any client libraries working from the CLI portion. Is there an easy to use python library for sockets similar to requests I should be using for this transition, or am I going in a totally wrong direction with making this switch?
Another option, unsure of the viability, would be to try and keep both the REST API for the CLI and have sockets for the web interface. Sounds very messy though.
After doing a lot of searching and messing around with various libraries, the one that was easiest to get up and running connecting a command line tool with a Flask-SocketIO webapp was socketIO-client.
This repository came in handy for the issues where I was struggling to understand how to correctly use the waits to receive info on the client side.
Once I've finished the project in a few weeks, I will come back and add more details so people finding this in the future can have an easier time getting this set up.
Ok, I get that CGI is sow outdated, and no one likes it, but I have a customer who needs a new site, is on shared hosting, and does not wish to change hosting providers. We are doing the back-end of his site in Python, and are researching Python framework options that can run as CGI(no one wants to just use the CGI module). So far, It seems Django can be run on CGI, but it is terrible. Flask and Bottle seem to run well on CGI(at least it is supported), but I was wondering if the Pyramid Framework can. If not, I guess we will just be using Flask. Can I get Pyramid running on CGI? If so what would be the performance against running Flask r Bottle under CGI?
See this solution here, it shows how to use WSGI on CGI
https://www.python.org/dev/peps/pep-0333/#the-server-gateway-side
Take a look at wsgiref as well
https://docs.python.org/2/library/wsgiref.html
example :
https://github.com/w1mvy/twitter_bot_on_gae-py/blob/55754d0ec1580b67f7f0c710f5cf3456313cff4d/app.py
I am developing my web app with Python 2.7 + Bottle. Everything is great and python is an amazing language coming from ASP.NET. I am building a web application that needs to use real-time client/server communication and socket.io for node.js comes to mind.
I wanted to know how can I implement socket.io-like using Python + bottle. I've read this article on bottle, but I can't still seem to understand how it works - what I need to install, and how all works out (code examples?).
I really need that for my next web application but need help in understanding what I need to put in my project in order for it to work. I have no problem working with 'preview' codes which aren't stable release yet. I'm developing on Windows platform. Thanks.
I also want to know if its scalabe. whether I can use redis in the back so all calls will be sync when running my website on several servers, so when one client send data, all the other clients connected to the other servers will get it to.
maybe websocket can help you,many modern browser support this protocol,but bottle.py don't support it now,you can get some idea from tornado.websocket and some answer here
cause every connection can be saved,so i guess it can run on several servers,but i never implement.
since bottle is micro framework,you should do something by yourself.