7

I was approached by a friend a few days ago - who has very little programming experience, and he has a project that he asked for some help with.

Basically - this is what he is attempting to accomplish:

1.) Create a website that can accept text files as input.
2.) Read said file and pass the parameters contained in the 
    file to a python script.
3.) Output these results of the script on the same webpage upon completion.

He knows a small amount of Python (enough to write the processing script), but he has no idea where to go from here. I made a quick example for him using an ASP page that read in a file, and used IronPython to pass the parameters into a script file and output the results, which worked just as I had expected it.

However - for him I was hoping to guide him in the right direction of developing a much simpler application to perform this and was hoping to find some suggestions or hear some thoughts on different approaches. I figure due to his lack of experience the simpler, the better.

Thanks guys.

2

3 Answers 3

6

Flask is dead-simple, extremely powerful, and intuitive. I prefer it over Django for smaller projects, as Django uses way too many folders (just follow the introduction tutorial). Here's what I mean by simple and intuitive. I can't really explain it in words, so here's an example script:

File: script.py

app = Flask(__name__)
app.config.from_object(__name__)

@app.route('/')
def index():
  return render_template('index.html', message = 'Hello')

if __name__ == '__main__':
  app.run(host = '0.0.0.0')

File: index.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"  http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 
  <head>
    <title>Test</title>
  </head>

  <body>
  {% if message != 'nope' %}
    {{ message }}
  {% endif %}
  </body>
</html>

Just my thoughts, so good luck.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks Blender - This was exactly what we were looking for! :)
No problem. The online documentation is more or less the only place to find anything about Flask, but it's probably the only thing you'll need: flask.pocoo.org/docs
Heh, while I was writing the example code, I accidentally overwrote my whole 500 line library application by saving this file. Good thing I deleted a Tarball of the source beforehand!
3

Maybe he see to Flask? http://flask.pocoo.org/ Very simple web-framework in Python for fast creation a small web-site.

Comments

0

If your friend wants to get something together very quickly and easily and doesn't have much programming experience, I think his best bet would be web2py. It requires no installation or configuration, has no dependencies, and includes a web server, a relational database, and a web-based integrated development environment and admin interface (demo).

It's very easy to learn and was designed for ease of use and developer productivity. You can get a lot done with very little code thanks to the included scaffolding app along with many sensible default behaviors. If the app gets more complex, web2py can handle it, as it is a well-integrated full-stack framework with lots of built-in functionality, including a database abstraction layer, form handling and validation, access control, web services, and easy Ajax integration.

If he needs help getting started or has any questions, he'll get lots of help from the very friendly and responsive mailing list.

Here's the complete working web2py equivalent of @Blender's Flask app (though this version adds a nice default layout with a menu as well as internationalization support to translate the 'Hello' message):

File: default.py

def index():
    return dict(message=T('Hello'))

File: index.html

{{extend 'layout.html' # optional}}
{{if message != 'nope':}}
{{=message}}
{{pass}}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.