Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I have an app that I am working on that is currently hosted on google App engine. It is written in python and went pretty smoothly until my requirements changed and google app engine would not let me do what I needed to do. Currently I am trying to find a way to host my code (python) and be able to make and accept http:// requests, and be able to edit/add files in the same directory as the python scripts are located (I need to store lots of files, and the blobstore is just weird).
If this is not possible, I would be happy with being able to run python scripts "in browser" like when testing with google app engine, just on my local machine (windows 7 64 bit).
Any help is appreciated
Google's App Engine supports WSGI , not CGI.
You should be able to port your code to another stack that supports WSGI rather painlessly. There isn't much custom google-specific stuff on there.
Some popular frameworks that support WSGI include:
Pyramid
Tornado
CherryPy
bottle
flash
web.py
twisted
There are lots more
In terms of hosting:
Heroku can host Python WSGI apps
You can deploy on virtually any machine with uwsgi , apache's mod_wsgi, or countless other wsgi servers
Most frameworks have their own server for local development
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
So the company I work for is very restrictive in giving software out to a large number of employees. I was asked to create a small desktop app that takes in certain parameters from the user and queries an internal database and outputs a csv with the results. I made this app in python. However, the organization is being stringent and not allowing me to load python onto everyone's laptops. Is there anyway to make this app usable by everyone without having python downloaded onto their computers?
As of right now, the app is hosted in an application and database server only accessible by my team and IT. We have access to docker but I'm not too experienced with that so I'm not sure if that would help.
You could run your app through pyinstaller. That creates a .exe installer file. Your network overlords may, or may not, allow you to distribute that installer to employees. You should ask before you do any more work in that direction. Big orgs are really reluctant to deploy desktop apps widely. Because cybercreeps and security compliance.
You could rework it into a web app that people can use via their web browsers. Downloading .csv files from web apps is simple. And, hitting your database from the server running the web app is plenty more secure and scalable than hitting it from lots of desktop apps. And, web apps are easier to update when needed.
There are a whole mess of web app frameworks for python available. Ask whether your org has chosen a particular one. If so, use it: you'll have programming and deployment expertise to draw on as you finish this project.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I have searched. Everything I can find is a huge file. It can't be that hard. C# has a SaveAs, PHP uses the $_FILES array. Python was all over the place. Cgi, httprequest, urllib, urllib2, httplib2, how to do it in Django, Pylons, Flask, etc. Java was complex as well.
All I want to know, please, is what is the most super-basic way to upload a file from a webpage.
Python 2.7 or Python 3 made no difference in my search.
Any help is appreciated.
EDIT: For clarification, I mean like any webpage that has the "Upload" button. Could be here, Craiglist, anything. All I really want to do is upload an image file and save it on the server.
EDIT: Part of the problem is there are so many libraries and everyone saying to use x.
EDIT: The server could be Apache or IIS.
"What is the simplest way to upload a file in Python from a web browser?"
I don't think there is a simple way, because this question doesn't make much sense. There are at least three ways to interpret this question :
If you want to upload a file with Python acting as a web-browser onto a remote server, one of the easiest ways is to use the requests library.
If you want to upload a file from a web browser, which Python is controlling, onto a remote server, then you could use the selenium library to drive a firefox browser.
If you want to upload a file with a web browser onto a remote server that is running Python, there is no "simple" way to do it. Python doesn't have the "it just runs" integration with apache like PHP does. While there are some open source projects for getting Python to work in Apache, most people opt to run their Python code either as it's own daemon or through some sort of WSGI server or proxy.
The simpler ways to handle #3-
The easiest way to do web stuff is web.py. Its very simple and limited.
If you're willing to do a bit more work, there are micro-frameworks like flask and bottle
There's another tier of minimalist frameworks, which contain pyramid, tornado, twisted, cherrypy and more. they tend to be very powerful, but don't make any decisions for you. Someone posted this link the other day comparing a few - http://codecondo.com/14-minimal-web-frameworks-for-python/
Finally you have full-fledged frameworks like django , turbogears, web2py, which make a lot of decisions for you.
Generally speaking, each framework deals with the GET/POST data from the request differently. While the cgi package is often wrapped, there's no real consensus on which library should be used to handle file uploads. A lot of frameworks seem to integrate webob to handle that stuff in a WSGI stack.
/updated/
Some simple ways to get python up and running:
most frameworks will offer a lightweight daemon for testing or low-load conditions. you can just run it as-is off the commandline , and it will bind to a high port (like 8080)
you can have Apache/IIS proxy requests to the higher port if you don't want to hit it directly
you can use something like gunicorn, uwsgi, eventlet, or probably 12+ other libraries to run the uwsgi environment.
personally, I do this
nginx on port 80
development - proxypass to the script's test-daemon, running on higher port ( for Pyramid/Pylons that is paster, for web.py it's just the commandline )
production - run via uwsgi
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
now bear with me please. I'll explain from the beginning but very briefly.
8 months ago, I worked in a web project with python, that used no framework (from scratch). I limited myself to implement views and templates, but with the pass of the months I became curious so I made some research.
Now I'm checking about WSGI and how to make "do-it-yourself" frameworks. But I'm a bit curious about some things. When I was in that project 8 months ago, we used a web server, but I remember in the web there was a "web server" component too.
The component was Tornado Web Server, and this other server was nginx. Now, what's the difference between one and the other server?
And if the component (Tornado or another one) is not the only thing I need for deployment, what else I need?
To clarify:
Tornado is a Python web framework and asynchronous networking library.
That's their own definition, not mine. (https://pypi.python.org/pypi/tornado)
Tornado can function as a web server as well. Some Python web development frameworks don't really function as a web server - they need to be bootstrapped onto another library for development work. Others can function as a web server, but don't recommend it - they were designed to write code, not build it.
If you're inclined to do so, you can serve everything from Tornado directly. Most people - including the Tornado development team - have seen much better performance by putting Tornado behind nginx , and using nginx to load-balance and serve static content. http://www.tornadoweb.org/en/stable/overview.html?highlight=nginx
There are many different ways to deploy WSGI applications to the internet. Some of them include:
Directly deploy the app on port80
Use nginx/apache as a public load-balancer:
proxy connections to the app running on a local port
run the app under uwsgi, configure the public load-balancer to proxy requests to uwsgi
There are also other ways to deploy WSGI apps using gunicorn, eventlet, twisted, and countless other networking or web serving libraries.
To answer your question :
In the project you worked on, nginx functioned as a public facing web server. Tornado (most likely) functioned as both a web framework and a private web server.
Xanathos, the component you mentioned Tornado is a web server for dealing with an extremely large amount of simultaneous connections. It is built on Twisted Python, and I would not recommend using it if you are still a beginner. I might suggest that you look into Python Werkzeug as it will give you a good introduction to WSGI.
Edit:
If you want something that is a very light framework you may also be interested in Flask
Tornado is a web server for use by Python web applications.
nginx is a more generic web server that you use typically as a front in front of other webservers to do virtual hosting or other proxying. It competes primarily with Apache.
So they are both web servers, but the do completely different things.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I'm trying to learn python/django, these are installed on my desktop computer and all the examples run fine. My question is: If a webhosting service supports python (2.4), does the webhosting service supports django by default?
Thanks guys.
You can use Google App Engine, which is free and includes Django.
Yes, but if they only support Python via CGI then your application will be very, very slow. Best is WSGI, then FastCGI, then mod_python.
Not necessarily.Many web hosting companies(shared) claim to offer django but this is a big lie.Case in point,a2hosting claims to have django but don't offer it;its disallowed.I tried to compile my own python and install django and found out that that path is also closed.
Django is memory intensive and will only work on vps and dedicated accounts.Web faction though is the only web host that wont lie to you.
Try Fornex VPS. https://fornex.com/vds/
I use it and like very much. Month payment starts from 5 euros. And you can install apache 2 + wsgi.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I would like to start writing Python web apps, first start simple like servlets in Java, then move to some web frameworks.
What server could I use to develop the apps? Is there a Tomcat version for Python? Is Apache with mod_python the way to go or something else?
I would like to know some options that may help with:
Python based local web development in my own laptop/ PC.
Creating production ready Python web applications.
Thank you!
PS: It is for Python 2.6.5, if that makes a difference
Tomcat is as far as I know only for Java.
You could use the Django-Framework. It has a integrated developmentserver and you can use Apache for a productive enviroment. But i recommend mod_wsgi instead of mod_python.
Here is an example for an wsgi application with apache and django:
# Apache Config
<VirtualHost *>
ServerName example.com
WSGIScriptAlias / /var/www/example/site.wsgi
ErrorLog /var/log/apache2/error.log
</VirtualHost>
# site.wsgi
import os
import sys
sys.path.append( rel(".") )
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
I realize this question was posted a long time ago, but Zope would be an alternative
http://www.zope.org/
There is Django. I guess this could do the job.
Here is a good overview about this.
CherryPy http://www.cherrypy.org/
Google AppEngine appengine.google.com
Apache mod_py apache.org
lighthttp must also have python
support lighthttp.org
I would highly suggest learning Twisted. It makes webservers easy. It is an asynchronous framework the relies on the idea of callbacks. You set up a server. You define how the server responds to different inputs. And then as it receives data it will call the proper methods to handle each incoming request. the twisted.web http module is also very robust yet easy to step into. Great place to start.
See: the following