├── .gitignore ├── requirements.txt ├── templates ├── thanks.html └── index.html ├── app.py ├── cats.html ├── notes └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | ENV 2 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | Flask==0.10.1 2 | Jinja2==2.7.3 3 | MarkupSafe==0.23 4 | SocksiPy-branch==1.01 5 | Werkzeug==0.9.6 6 | httplib2==0.9 7 | itsdangerous==0.24 8 | six==1.8.0 9 | twilio==3.6.7 10 | unittest2py3k==0.5.1 11 | -------------------------------------------------------------------------------- /templates/thanks.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Thanks for your order to Gerlanda's Pizza 5 | 6 | 7 |

Thanks for submitting your order for "{{ order }}". Your total is ${{ amount }}.00

8 | 9 | 10 | -------------------------------------------------------------------------------- /templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Gerlanda's Pizza - Busch Campus 5 | 6 | 7 |

Welcome to Gerlanda's Pizza

8 | 9 |

Items on the Menu

10 |
    11 |
  1. Pepperoni
  2. 12 |
  3. Sausage
  4. 13 |
  5. Plain
  6. 14 |
  7. Veggie
  8. 15 |
  9. Sicilian
  10. 16 |
17 | 18 |
19 |

Please enter your order below

20 | 21 |
22 | 23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /app.py: -------------------------------------------------------------------------------- 1 | from flask import Flask, render_template, request 2 | import random 3 | from twilio.rest import TwilioRestClient 4 | 5 | account = "" 6 | token = "" 7 | client = TwilioRestClient(account, token) 8 | 9 | app = Flask(__name__) 10 | 11 | @app.route('/') 12 | def home(): 13 | return render_template('index.html') 14 | 15 | @app.route('/process') 16 | def process(): 17 | # write any python code here. 18 | 19 | amount = random.choice(range(3, 8)) 20 | order = request.args['order'] 21 | message = client.messages.create(to="+17327252998", from_="+1 7328527245", body="Someone ordered %s " % (order)) 22 | return render_template('thanks.html', amount=amount, order=order) 23 | 24 | 25 | if __name__ == '__main__': 26 | app.run(debug=True) 27 | -------------------------------------------------------------------------------- /cats.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Welcome to Hacker Hour 5 | 6 | 7 | This is my first web page. 8 |

This is a heading.

9 | 10 |

This is a really long paragraph of text in HTML. It has some bold text , some italic text . Here is 11 | a link to my blog .

12 | 13 | 14 | 15 |

Here is a list of things I love

16 | 17 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /notes: -------------------------------------------------------------------------------- 1 | HTML stands for Hypertext (Markup Language) 2 | HTML should remind you of Microsoft Word. 3 | HTML is the language of the web. 4 | 5 | HTML is a client - server interaction. The client is usually a web browser, the server is something like google.com 6 | 7 | The HTML code I wrote represents a simple web page. 8 | 9 | HTML is not a programming language. It cannot perform Input/Output. 10 | 11 | To do input/output, we will use Python - specifically Flask. 12 | 13 | Web Server in Flask - Map HTTP Requests to HTTP Responses. 14 | ( URL ) -> HTML 15 | 16 | Gerlanda's home page here is: 17 | http://localhost:5000/ 18 | 19 | After clicking submit the page is: 20 | http://localhost:5000/process?order=plain+pizza 21 | 22 | We showed how we can write HTML code to show things on webpages. 23 | 24 | We showed how we can do simple input/output using Python/Flask 25 | 26 | We showed that you can write any Python code (even send a text message) when you're writing a dynamic web site. 27 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Flask Talk Fall 2014 2 | ============== 3 | 4 | This repository contains code, and action items from a Intro to Web Development in Flask talk given on September 29, 2014. 5 | 6 | ## Code 7 | 8 | `cats.html` shows you how to write a simple static web page - something that looks like a Microsoft Word document. 9 | 10 | `app.py` shows you how to do input/output on the web. It allows us to accept orders from customers, show them a "thanks for your order" page, and notify someone via text message of the order. You will need to sign up for a Twilio account and fill in your account information in `app.py` to get the text messages to work. 11 | 12 | ## Takeaways/Action Items 13 | 14 | - Writing web code is easier than it looks. I've written less than 150 lines of code that already does something useful. 15 | - I encourage you to think of a simple web application that you'd like to build - you will be far more motivated to work on a project that you find interesting. 16 | - Talk to upperclassmen, mentors or send me an email (vaibhav2614@gmail.com). The CS community is happy to help motivated students, and point you in the right direction. 17 | - It sucks that this stuff - HTML, Python, Flask - isn't taught in our CS classes. Don't use that as an excuse. Remember that you're responsible for your own success. 18 | - Go to [HackRU](http://hackru.org) and build stuff. You'll get inspired by the people and the environment. 19 | - Don't worry about the language, environment you're writing in. People will tell you X is better than Y, and the discussion turns into a religious debate. Learn from the people around you but don't feel compelled to do things exactly like they do. 20 | - As an exception to the previous rule - stop trying to write web apps in Java/Eclipse. Java is generally full of boilerplate, and makes web development harder. I know that you're comfortable in Java because of your coursework, but the initial investment into learning Ruby/Python/Node.js/PHP pays in the long run. 21 | 22 | ## Resources 23 | 24 | - [Learn Python the Hard Way](http://learnpythonthehardway.org/book/) - Teaches you the basics of Python. Good for people new to programming. 25 | - [Project Euler](https://projecteuler.net/) - Interesting math-y problems that you can use for code practice in any language. I recommend picking up Python by doing the first ~10 problems if you've already taken 111/112. 26 | - [Flask Docs](http://flask.pocoo.org/) - Flask docs. They're pretty well written with code examples, and well written explanations of concepts. 27 | - [CS75.tv](http://cs75.tv/2012/summer/) - A comprehensive dynamic web development course that walks you through HTML/CSS, PHP, Databases, Javascript, Security etc. It gives you a very strong foundation in web development concepts, and it's useful if you prefer a more organized cirriculum. 28 | - Google, StackOverflow, [Rutgers Hackathon Club](http://hackathonclub.com/) 29 | 30 | P.S. - I work for [Etsy](http://etsy.com/) - a wonderful software company in Brooklyn. If you're interested in an internship or full time position with us, shoot me an email (vverma@etsy.com). 31 | --------------------------------------------------------------------------------