I'm new to the python world and I'm currently in a new project using it. So since we we're there to learn, we chose to start with python 3. Now, we need to make a RESTful web service. After reading a few, I found out that the most used framework for web services is Django... and I also read on the Django website that it does not yet supports python 3.
Is there any other API that I could use in order to make a RESTful web service?
Thank you.
CherryPy has a Python 3 branch. Not sure how advanced it is, but if Fu-manchu passes by this question, he will be able to tell you.
The Bottle framework claims to work with Python 3. You might inquire on their google group for details.
I really like to use bottle and run it on cherrypy. This is really easy, do everything per bottle instructions, and then in the run line, tell it to use cherrypy as it's server.
Exampple:
app.run(host='localhost',
port=8080,
server='cherrypy',
reloader=True,
debug=True)
Related
I'm coming from a php background and now I'd like to host a Python web application on AWS but have a few questions about it.
Do I need to use a framework like Django/Flask? Is there anyway I can use core Python to do the same? Back in php, although I tried learning Laravel in the middle, I was able to just use core php with apache and host up my website.
Tried deploying my Python code on my AWS but got an error that application.py was missing. I'd like to know, what exactly is application.py and what is it supposed to contain? Similarly, what's wsgi.py I see here and there. Are these actual files I need to create for the web app to be hosted? Is there some specific code that has to go into them or are the pre-created files by frameworks like Django, etc? Because I could hardly find too much information on them online.
I had recently tried following this tutorial from the AWS official site but to no luck.
The reason for being reluctant to use Django is the shortage of time to learn it. But if it were to make the task of hosting a Python web app easier, I would definitely look at it.
And how is the version of Python set? Because the Python codes I've written use the python3 libraries for BeautifulSoup and urllib.
I have read a lot of articles on the web but the first thing I get on searching for Python on the web or with AWS, is Django or Flask or something. How exactly does it work? When it came to php, it was simple copying the files into the /www/ folder of the server machine and I could access the website via it's url. Maybe I've read too many posts to put them all together so could someone please set it straight for me? It would be greatly appreciated!
Thanks a lot!
You will waste a lot more time trying to write a WSGI application yourself from scratch. Use a framework, it will save you a lot of time.
PHP is very different to WSGI and WSGI sits well below the level of functionality that PHP provides out of the box. PHP is more like what frameworks in Python provide. So go learn a framework. If Django seems too complicated, try Flask first.
Also don't try and do it on AWS from the outset, learn the frameworks by using the development servers they provide on your own box. Just work through their respective tutorials.
Actually AWS Elastic Beanstalk give you pure Python (2.6/2.7/3.4) with Apache + mod_wsgi as web proxy. You can look all supported Python environment in here. So, you can use any Python web framework (such as Django, Flask, etc.) in your web app. If you can, choose common and supported framework by AWS (Django/Flask).
You can think: Python + Apache + mod_wsgi is equivalent to PHP + Apache + mod_php.
Please take a look into AWS Elastic Beanstalk documentation for how to working with Python here. Read the Deploying a Django Application or Deploying a Flask Application if you choose one of them. You need to provide what Elastic Beanstalk environment (mod_wsgi) needs.
Same as PHP, Python actually only copy and paste the files. If you want to make Python web app without framework, you need to follow the WSGI standard. You can take look into this question. In my opinion, better if you use a framework, because it handles the WSGI part for you.
First of all this is a good blog post to start from if you are using Django
I don't know much about Flask, with Django once you understand the core concepts it's not hard at all.
application.py is the file that aws looks for as stated in the blog post I pointed to:
By default eb assumes our wsgi file is called application.py
this can be changed to your local wcgi.py file that Django makes when you start your project with django.
Beware that you want to use your static url correctly so aws will read them from the right folder. I personally disagree about the way the static files configuration in the post.
It's better to stay with the aws default which is "static" and just set static url in django settings to "/static/"
As the title said, just wonderring how to use python or anyhow to include executable python script into HTML
Using django to do this.
django official web:
https://www.djangoproject.com/
I would look into the python documentation here for learning about Python in the web. But more specifically, there is documentation here explaining Common Gateway Interface (CGI) and how to use it. I recommend looking into this first because I am unsure what exactly you need help with, if it is simply wondering how it works, then these links will explain that just fine.
Flask is very simple micro framework for writing web applications in python.
http://flask.pocoo.org
I have developed a few python programs that I want to make available online.
I am new to web services, and I am not sure what I need to do in order to create a service where somebody makes a request to an URL (for example), and the URL triggers a Python program that displays something in the user's browser, or a set of inputs are given to the program via browser, and then python does whatver it is supposed to do.
I was playing with the google app engine, which runs fine with the tutorial, and was planning to use it becuase it looks easy, but the problem with GAE is that it does not work well (or does not work at all) with some libraries that I plan to use.
I guess what I am trying to do is some sort of API using my WebFaction account.
Can anybody point me in the right directions? What choices do I have in WebFaction? What are the easiest tools available?
Thank you very much for your help in advance.
Cheers
Well, your question is a little bit generic, but here are a few pointers/tips:
Webfaction allows you to install pretty much anything you want (you need to compile it / or ask the admins to install some CentOS package for you).
They provide some default Apache server with mod_wsgi, so you can run web2py, Django or any other wsgi frameworks.
Most popular Python web frameworks have available installers in Webfaction (web2py, django...), so I would recommend you to go with one of them.
I would also install supervisord to keep your service running after some reboot/crash/problem.
I would be glad to help you if you have any specific question...
I used to create web applications with Django framework, but now I have to create only simply web GUI for python application. I would be very glad if someone will recommend to me any small python web framework.
web.py is a popular choice for this sort of thing.
"web.py is a web framework for Python that is as simple as it is powerful."
And of course let's not forgot bottle!
I normally web develop in PHP. I am working on a python based project, and want to make a front-end web site for it.
I looked at web.py, and I was wondering if PHP can be used together with web.py, or would I have to rely completely on python as the server side scripting?
Thanks.
Combining web.py and PHP doesn't really make sense. But you can definitely set up Apache to have both. You just install mod_php and mod_wsgi. Point mod_wsgi to your web.py WSGI function, and set up your PHP web app in some directory where Apache can find it. You won't be combining the two technologies, but you will have separate web applications on your server that separately use the two technologies.
If you're using web.py, you should probably go with Python for server-side scripting. Mixing Python and PHP is definitely possible, but it seems to be going a little too far just to get the features of web.py.
Speaking of the features of web.py, if you want a similar framework I'm sure there are many which express the same principles.
There is one here: http://code.google.com/p/webpy-php-port/ (seems to be dead)
Good luck!