+ 1
Hey, I'm new here what can Python be used to create. And what server is best for execution / to run the program in a back-end
5 Respostas
0
Hi. Python is general purpose language. So it can be used almost anywhere. Try to Google your question.
0
Ok
Thank you very much Dmitiry
0
I personally used Python (with Django framework) to set up a web app doing a set of operations helping taxpayers in Poland (automation of compliance activities, XML files validation etc) so I'd say Python is great for automating stuff and web apps!
Edit/addition: My projects use a fairly common technical stack: Python/Django with PostgreSQL database, run on nginx with gunicorn.
0
From a clean Linux server installation:
$ sudo apt-get update && sudo apt-get install nginx
$ # Load config into /etc/nginx/sites-available/default
$ sudo service nginx restart
$ pip install gunicorn
$ gunicorn --access-logfile - -b 127.0.0.1:5000 ched.app:app
#------------------------------------------------------------------------
Use the pip and gunicorn programs in virtualenv. Load into the nginx configuration, changing localhost to your domain name if you have one:
server {
listen 80;
server_name localhost;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
location / {
proxy_pass http://127.0.0.1:5000/;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
0
Handling static files with nginx:
Flask provides a static file handler for convenience. Now that we have an optimized HTTP server in place, we can have it serve static files directly. The following configuration block shows how to serve static files with nginx and proxy all other requests to Flask. Adjust the configuration according to your setup
- Change /var/www/myproject to the filepath containing the sched folder from our project layout.f.
- Change /static/ if you changed the default static route in Flask.
The updated server configuration, to handle static files:
server {
listen 80;
server_name localhost;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
location /static/ {
# /static/ is appended to root path on the request.
root /var/www/myproject/sched/;
}
location / {
proxy_pass http://127.0.0.1:5000/;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
Deployable on any OS with HTTP proxying:
----------------------------------------------------
I prefer to run applications in production using HTTP proxying with application code served by stand-alone, independent operating system processes. Most industrial strength HTTP servers include a means to proxy requests to another web service, just as we demonstrated with nginx. gunicorn only runs on Unix-like systems, but cherrypy (cherrypy.org) provides a cross-platform WSGI server. You can start your application with a script which follows this example.
#WSGI.py
#--------
from cherrypy.wsgiserver import CherryPyWSGIServer
from sched.app import app
server = CherryPyWSGIServer(('127.0.0.1', 5000), app)
server.start()