How To Use Python for a Web App? [closed] - python

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I am creating a school management system that handles file uploads and downloads from teachers and students. Furthermore, there will be a large amount of database writes and reads (e.g. which classes a student is taking, what the student's grades are etc.)
I want dynamic web pages updated with python using an AJAX model on the front end.
On the back end I want to use python for file handling, database reads to show user their content, database writes when a user updates his/her content on the web app and memcache.
The stack I am using is...
CentOS + Hadoop + Hypertable + Python
I am currently going through the Pyramid docs and after going past a few chapters, I don't see how pyramid helps me accomplish what I can do in PHP, and if it does do this, why so complicated?
Is pyramid the right tool, or should I be using web2py?
If pyramid is the best tool, where can I see some sample code of a complex application built in pyramid. I tend to understand best when reading other's code.
Django cannot be used due to inflexibility

I don't see how pyramid helps me accomplish what I can do in PHP, and if it does do this, why so complicated?
A web framework like Pyramid is not a web framework like PHP. They're different.
Complexity is a matter of "experience". If you're experienced with PHP, Python seems complex. If your experienced with RoR, PHP seems complex. Everything that's new seems complex.
Python has a dozen or so web frameworks of varying capabilities. None of them will look like PHP. Zero. They'll all be different (and appear complex).
Consequently, if you don't like one. Move on. There are a lot of choices. Keep trying different ones.
Ask specific questions. "I don't see how pyramid helps me accomplish what I can do in PHP" is too vague to discuss further. If there's a specific thing you want to know about, search for that specific question (it's probably already been asked). If you don't find anything, ask the specific question. Code samples help.

I highly recommend you use Django.
https://www.djangoproject.com/
Django is a great way to do a project like this, and the documentation is outstanding. There is a free book, called The Django Book, which you can read online.
http://www.djangobook.com/
This book is a few years out of date. I haven't been keeping up with Django but I am pretty sure that the book will still be useful. Use the book to learn the concepts, and use the actual Django documentation to look up specifics.

I've had some great luck with Django, its pretty well documented and has examples that do exactly what you seem to do

Related

Building HTML5 based GUI in python [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
Recently I was at a conference and one company had a software product which had a GUI written in HTML 5.It was rendered to the user via their custom built browser and looked quite good. I never heard of such concept and I am wondering if this is a common practice? I can see some benefits being able to produce flexible and stunning UI designs. Are there any tools available in Python? I assume you just need a browser able to render static pages with HTML and CSS. Also what would be the disadvantages of such approach?
This is the closest I found https://github.com/html5lib
If you're going to send it in HTML5, I see no reason to build a browser though, there are already many browsers, that have more people working on them, you'd be hard pressed to beat something like Firefox or Chrome, unless you have a specific feature you want, and then a plugin might be better. Generally building a custom browser like that is only useful if you either only want to do one very limited thing (like streaming a movie) or you want to use a different format (something like sending your version of HTML in an XML doc and parsing that and rendering it).
I also personally don't think Python is what you want to do this with, simply for a lack of compatibility with pretty much everything else at the current moment (not that you couldn't make things work, but it's not like you're going to download a Chrome plugin, change 3 lines of code and load it into your browser). I did see an example web browser in the wxPython docs, you could start there, I don't know what it does and what it doesn't do though unfortunately.

Web interface for a Python code [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
first, English is not my native language, so, forgive me for any mistake.
I don't want to make a evasive question, so i will detail my scenario and make my point below:
I need to make a Web interface to take a information from a html's form field. Specifically a text file. Then, i need to give this file as a paramater to a Python Script that will run on my Linux server (the same who was the Web interface). I have the script running okay, have the Web interface ready, but i didn't get the point to make the web stuff works.
I'm stuck on the part of "make the wweb form talks with python script".
I tried some linux commands and some tips found on my research, but didn't work.
The goal of this thing, is to not send the Python code to end-user. So, the clients will "use" the code from a web interface and will not see the Python code responsable for make the hole stuff works.
Does anyone ever seen this kind of implementation?? Any help or information will be nice ! Tks a lot !
You should probably start with this page from the Python documentation - http://docs.python.org/howto/webservers.html. This may give you some ideas about how this works, and depending on what you need you may then continue reading about more detailed topics. Solution will depend on your plans for further development (will you extend the logic of this application? will you connect to the DB, etc.), security concerns, etc.
For only the case you define, it sounds like some simple solution will work for you, like having a simple CGI script ( http://docs.python.org/library/cgi.html), and you probably don't (yet) need anything powerful like Django or TurboGears.
For CGI to work, you will need to configure Apache web server, enable CGI for it, and then implement the CGI script utilizing your already implemented program.
You may check on the web how to do each of those steps. For example, right here, on stackoverflow: How do you set up Python scripts to work in Apache 2.0?
In your CGI script, you will need to implement some logic which will allow users to upload files to your server. You may check this page for that: http://code.activestate.com/recipes/273844-minimal-http-upload-cgi/
Finally, if with time you plan to further develop your application, you may want to look to something like Django or TurboGears. The more complex your application is - the better it is to use some web framework. You will probably spend more time studying those, but in the end you get much more power with them, and you get the code which is much more easier to maintain compared to CGI scripts. But, just as I said - it depends on your needs. (Although studying them is a good idea anyway ;) )

Personalizing Online Assignments for a Statistics Class [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I teach undergraduate statistics, and am interested in administering personalized online assignments. I have already solved one portion of the puzzle, the generation of multiple version of a question using latex/markdown + knitr/sweave, using seeds.
I am now interested in developing a web-based system, that would use the various versions generated, and administer a different one for each student, online. I have looked into several sites related to forms (google docs, wufoo, formsite etc.), but none of them allow programmatic creation of questionnaires.
I am tagging this with R since that is the language I am most familiar with, and is key to solving the first part of the problem. I know that there are several web-based frameworks for R, and was wondering whether any of them are suitable for this job.
I am not averse to solutions in other languages like Ruby, Python etc. But the key consideration is the ability to programatically deliver online assignments. I am aware of tools like WebWork, but they require the use of Perl and the interfaces are usually quite clunky.
Feel free to add tags to the post, if you think I have missed a framework that would be more suitable.
EDIT. Let me make it clear by giving an example. Currently, if I want to administer an assignment online, I could simply create a Google Form, send the link to my students, and collect all responses in a spreadsheet, and automatically grade it. This works, if I just have one version of the assignment.
My questions is, if I want to administer a different version of the assignment for each student, and collect their responses, how can I do that?
The way you have worded your question it's not really clear why you have to mark the students' work online. Especially since you say that you generate assignments using sweave. If you use R to generate the (randomised) questions, then you really have to use R to mark them (or output the data set).
For my courses, I use a couple of strategies.
For the end of year exam (~500 students), each student gets a unique data set. The students log on to a simple web-site (we use blackboard since the University already has it set up). All students answer the same questions, but use their own unique data set. For example, "What is the mean". The answers are marked offline using an R script.
In my introductory R course, students upload their R functions and I run and mark them off line. I use sweave to generate a unique pdf for each student. Their pdf shows where they lost marks. For example, they didn't use the correct named arguments.
Coupling a simple web-form with marking offline gives you a lot of flexibility and is fairly straightforward.
I found one possible solution that might work using the RGoogleDocs package. I am posting this as an answer only because it is long. I am still interested in better approaches, and hence will keep the question open.
Here is the gist of the idea, which is still untested.
Create multiple versions of each assignment using knitr/Sweave.
Upload them to GoogleDocs using uploadDoc.
Share one document per student using setAccess which modifies access controls.
Create a common Google Form to capture final answers for each student.
The advantage I see is two-fold. One, since all final answers get captured on a spreadsheet, I can access them with R and grade them automatically. Two, since I have access to all the completed assignments on Google Docs, I can skim through them and provide individual comments as required (or let some of my TAs do it).
I will provide an update, if I manage to get this working, and maybe even create an R package if it would be useful for others.
I know that this was asked a long time ago, but I think that today the best solution is the package exams plus Moodle.
The package exams can now generate XML Moodle questions that can be upload to Moodle platform as the students can solve the exercices on-line.
This is an example of a question made with exams package and uploaded to Moodle.
i just stumbled upon the ?exams package in R: Link to the CRAN site. could this be something for you?

Where can I find Python code examples, or tutorials, of social networking style functions/components? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
I am looking for tutorials and/or examples of certain components of a social network web app that may include Python code examples of:
user account auto-gen function(database)
friend/follow function (Twitter/Facebook style)
messaging/reply function (Twitter style)
live chat function (Facebook style)
blog function
public forums (like Get Satisfaction or Stack Overflow)
profile page template auto-gen function
I just want to start getting my head around how Python can be used to make these features. I am not looking for a solution like Pinax since it is built upon Django and I will be ultimately using Pylons or just straight up Python.
So you're not interested in a fixed solution but want to program it yourself, do I get that correctly? If not: Go with a fixed solution. This will be a lot of programming effort, and whatever you want to do afterwards, doing it in another framework than you intended will be a much smaller problem.
But if you're actually interested in the programming experience, and you haven't found any tutorials googling for, say "messaging python tutorial", then that's because these are large-scale projects,- if you describe a project of this size, you're so many miles above actual lines of code that the concrete programming language almost doesn't matter (or at least you don't get stuck with the details). So you need to break these things down into smaller components.
For example, the friend/follow function: How to insert stuff into a table with a user id, how to keep a table of follow-relations, how to query for a user all texts from people she's following (of course there's also some infrastructural issues if you hit >100.000 people, but you get the idea ;). Then you can ask yourself, which is the part of this which I don't know how to do in Python? If your problem, on the other hand, is breaking down the problems into these subproblems, you need to start looking for help on that, but that's probably not language specific (so you might just want to start googling for "architecture friend feed" or whatever). Also, you could ask that here (beware, each bullet point makes for a huge question in itself ;). Finally, you could get into the Pinax code (don't know it but I assume it's open source) and see how they're doing it. You could try porting some of their stuff to Pylons, for example, so you don't have to reinvent their wheel, learn how they do it, end up in the framework you wanted and maybe even create something reusable by others.
sorry for tl;dr, that's because I don't have a concrete URL to point you to!

web2py in the future? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
Given the size of web2py and the lack of resources and corporate support, do you think it would be advisable to learn web2py as the only web development framework I know. I'm considersing learning Ruby on Rails or web2py for a website I need to create for as a school project.
web2py does have a smaller market share than competitor products but it is also much younger. I have knowledge of at least 13 consulting companies that provide web2py support. Anyway, I do believe web2py is much easier to use than other systems and therefore you will need less support that you may think. Most of the current users get their support via the web2py google group where you can find 29781 messages and almost all questions have been answered within 24 hours by one of the contributors.
Learning is bad. Sherlock Holmes explains:
"You see," he explained, "I consider
that a man's brain originally is like
a little empty attic, and you have to
stock it with such furniture as you
choose. A fool takes in all the lumber
of every sort that he comes across, so
that the knowledge which might be
useful to him gets crowded out, or at
best is jumbled up with a lot of other
things, so that he has a difficulty in
laying his hands upon it. Now the
skilful workman is very careful indeed
as to what he takes into his
brain-attic. He will have nothing but
the tools which may help him in doing
his work, but of these he has a large
assortment, and all in the most
perfect order. It is a mistake to
think that that little room has
elastic walls and can distend to any
extent. Depend upon it there comes a
time when for every addition of
knowledge you forget something that
you knew before. It is of the highest
importance, therefore, not to have
useless facts elbowing out the useful
ones."
I'm sure I'm not the only one who has wasted an inordinate amount of time wading through the many bad and poorly documented Python web frameworks trying to find one I can just use. If I was programming in Ruby or PHP I probably would have spent that time actually writing a web application. This is the curse of web development in Python.
This bit of flamebait may help:
stackoverflow.com tags about web frameworks http://spreadsheets.google.com/pub?key=tZCdBPAkC75t27UzsPdLfMg&oid=2&output=image
Omitted from the chart are the 13,000+ questions tagged [php], but let's not go there.
To be clear, even though choosing a framework for Python web development can be confusing, once you decide on one you get to program in Python. This is the blessing of web development in Python. It can be really nice.
My advice is don't accept anything less than a framework with excellent documentation. With the amount of choices out there there's no need to settle for poor, incomplete docs. Failing that, the simplest frameworks, those lacking room for any magic, are pleasant to work with and quickly learnable.
web2py may be young, but the mailing list has ~2000 messages / month, which is similar to Django and far more than Turbogears. I usually get answers to my questions within a few hours.
There is also an excellent online book, but I find the best source of information is the mailing list.
I have used both RoR, Django, Turbogears, and web2py, and find web2py the most productive.
Learning is good.
Learning something (that eventually goes away) is no loss at all. The basic skills of web development (HTML, CSS, URL-parsing, GET vs. POST) don't ever change.
Frameworks come and go. Learn as many as you can. Learn how to manage your learning so that you (a) get to the important stuff first and (b) leave the other framework stuff behind when tackling a new framework.
Every framework has it's bias (or focus). Once you figure this out, you can make use of them without all the "compare and contrast" that slows some people down. Once you've learned web2py, you have to be careful learning Django that you start fresh, with no translation from old concepts to new.
Web2py is a good one to learn. If this is going to be deployed to a server, double check it supports wsgi. Sometimes php is the way to go because you know it's supported almost anywhere.
Ask yourself what you are looking to gain from the experience. Ie, is it more important to just get the application built and running with a minimum of time and effort, or are you trying to learn about web stack architecture?
If you're just looking for results, obviously you'll have more code and documentation to borrow from if you stick with a more commonly used framework. If you grit your teeth and accept Django's view of the world, you can build very functional applications very quickly. If you can find some pre-made reusable Django apps that handle part of your problem, it'll be even faster.
But if you want to make sure you have a very solid understanding of everything in the request cycle from HTTP request handling to database access and abstraction to form generation and processing and HTML templating, you'll be bettered served with a minimal framework that forces you to think more about the architecture and has a small enough codebase that you can just read it all top to bottom and not really need documentation beyond that. In that case though, I'd advise going even deeper and building your own framework on top of a WSGI library (you don't actually want to waste time learning the intricacies of working around browser quirks if you can help it). Once you've built your own and seen where things get complicated and where the tradeoffs are, you'll be in an excellent position to judge other frameworks and decide if there's one that does things the way you want to work.
This may seem slightly off-topic, but Paul Graham has probably the best essay on this subject that I have seen: The Python Paradox.
Let me put it this way, if you want to work for me, I notice this kind of free thinking and experimentation on a resume, whether the work was commercial, academic, or otherwise. And I'm pretty sure I'm not alone.
Glad I found this thread! Cause some outdated pages and broken external links on Web2Py's website almost scared me off. But at least now I know there's a pretty good community around Web2Py.
I've just been looking through a load of Python web frameworks, and Web2Py's description sounded enticing and managed to make Django sound overly laborious. Pretty sure there are some tangible benefits to Django's design decisions avoiding "too much magic" when it comes to larger projects.
But to just throw something up on the web with err "sane defaults" sounds perfectly good to me. Instead of throwaway scripts, we can make throwaway websites to handle some temporary thing...
There should be room for an appliance style framework with no installation...
Interesting possibilities for some projects. I saw someone already got a python framework + server to work on android phones :))
For me, thanks to this thread, I will just learn both.
Another thought; if Web2Py is open source and you like what it does you might not even mind being the only user at some point in the future, since you can add features to it yourself?
Mind you, I have not used either yet, just read the docs. I think the Web2Py people should put up a blurb on their website to differentiate themselves from Django in more detail, I haven't been able to check off all my question marks for choosing the right one.
I've already used Java EE and Django. The web2py learning curve is so fast! It's incredible! Things that I was getting a time to develop in three days using java, I can do fastly using web2py. Of course, Web2py has not the same ready plugins that RoR, but, doubtless, we can do these things fastly using web2py. Therefore, is a good opportunity to start learning = )
I'm agree with S.Lott saying that:"Learning something (that eventually goes away) is no loss at all."
YEAH It's true but let me suggest that also a scholastic project should be able to reach the better support possible, otherwise could be very frustrating and a waste of time to learn and teach something not well supported, debugged, stable etc.
The time you spent, and maybe your auditors/students, should in some sense projected with an eye to the future...
just for example take a look to turbogears

Categories