Last active
May 4, 2019 01:38
-
-
Save jeremyosborne/6114464 to your computer and use it in GitHub Desktop.
python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# pip install beautifulsoup4==4.2.1 | |
# pip install flask==0.10.1 | |
# | |
# https://gist.github.com/jeremyosborne/6114464 | |
import os | |
import re | |
import requests | |
from flask import Flask, render_template, request | |
BASE_DIR = os.path.realpath(os.path.dirname(__file__)) | |
STATIC_DIR = os.path.join(BASE_DIR, "static") | |
SCRAPE_URL = "http://www.craigslist.org/about/best/all" | |
def init(): | |
print "Downloading static content." | |
if not os.path.exists(os.path.join(STATIC_DIR, "normalize.css")): | |
print "\tnormalize.css downloading..." | |
response = requests.get("http://necolas.github.io/normalize.css/2.1.2/normalize.css") | |
with open(os.path.join(STATIC_DIR, "normalize.css"), "w") as f: | |
f.write(response.text) | |
else: | |
print "\tnormalize.css already downloaded" | |
app = Flask(__name__, | |
static_url_path="/static/") | |
@app.route("/") | |
def main(): | |
context = {} | |
return "Hello world!" | |
if __name__ == "__main__": | |
init() | |
app.run(port=5000, debug=True) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment