Skip to content

Commit 6a800e5

Browse files
committed
migration to seperate repo from web-microframework
0 parents  commit 6a800e5

File tree

8 files changed

+134
-0
lines changed

8 files changed

+134
-0
lines changed

Brewfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
brew "python"

Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM python:2-onbuild
2+
3+
# Create app directory
4+
RUN mkdir -p /usr/src/app
5+
WORKDIR /usr/src/app
6+
7+
# Install app dependencies
8+
COPY requirements.txt /usr/src/app/
9+
RUN pip install -r requirements.txt
10+
11+
# Bundle app source
12+
COPY . /usr/src/app
13+
14+
EXPOSE 5000
15+
ENTRYPOINT ["python"]
16+
CMD ["app.py"]

README.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# **Flask WebMF**
2+
3+
## **Using on Mac OS X Host**
4+
5+
* Prerequisites:
6+
* Install XCode Command Line Tools
7+
* Install Brew `/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"`
8+
9+
### **Install**
10+
11+
```bash
12+
$ brew install python
13+
$ # Install/Setup virtualenv (optional)
14+
$ pip install virtualenv
15+
$ pip install virtualenvwrapper
16+
$ mkdir ${HOME}/.virtualenvs
17+
$ source /usr/local/bin/virtualenvwrapper.sh
18+
```
19+
20+
## **Run**
21+
22+
```bash
23+
$ pip install flask # install flask library
24+
$ ./app.py # run program
25+
```
26+
27+
### **Run Using Virtualenv**
28+
29+
This uses [virtualenv](https://virtualenv.pypa.io/en/latest/), so that libraries are installed in locally in only your account.
30+
31+
```bash
32+
$ mkvirtualenv flaskenv # create segregated environment
33+
$ pip install -r requirements.txt # install flask library locally
34+
$ ./app.py # run program
35+
$ ## Run Tests Here (see below)
36+
$ deactivate # exit segregated environment
37+
```
38+
39+
## **Using Docker or Vagrant**
40+
41+
See [Tools Readme](../TOOLS.md) for more information on install, setup, and start Docker or Vagrant.
42+
43+
### **Build and Run with Docker Compose**
44+
45+
```bash
46+
$ docker-compose up -d
47+
```
48+
49+
### **Build and Run with Vagrant**
50+
51+
```bash
52+
$ vagrant up
53+
```
54+
55+
## **Testing Results**
56+
57+
```bash
58+
$ [ -z ${DOCKER_MACHINE_NAME} ] || WEBSERVER=$(docker-machine ip ${DOCKER_MACHINE_NAME})
59+
$ WEBSERVER=${WEBSERVER:-localhost}
60+
$ PORT=5000
61+
$ curl -i ${WEBSERVER}:${PORT}
62+
HTTP/1.0 200 OK
63+
Content-Type: text/html; charset=utf-8
64+
Content-Length: 13
65+
Server: Werkzeug/0.11.4 Python/2.7.11
66+
Date: Sun, 13 Mar 2016 07:02:41 GMT
67+
68+
Hello World!
69+
```

Vagrantfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# -*- mode: ruby -*-
2+
# vi: set ft=ruby :
3+
4+
Vagrant.configure(2) do |config|
5+
config.vm.box = "ubuntu/trusty64"
6+
config.vm.network "forwarded_port", guest: 5000, host: 5000
7+
8+
config.vm.provision "docker" do |docker|
9+
docker.build_image "/vagrant", args: "-t vagrant/flask-web"
10+
docker.run "vagrant/flask-web" , args: "-p 5000:5000"
11+
end
12+
end

app.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env python
2+
from flask import Flask
3+
app = Flask(__name__)
4+
5+
@app.route('/')
6+
@app.route('/hello') # this route is not working
7+
@app.route('/hello/')
8+
def hello_world():
9+
return 'Hello World!\n'
10+
11+
@app.route('/hello/<username>') # dynamic route
12+
def hello_user(username):
13+
# show the user profile for that user
14+
return 'Why Hello %s!\n' % username
15+
16+
if __name__ == '__main__':
17+
app.run(host='0.0.0.0') # open for everyone

chocolate.config

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="python2" />
4+
<package id="pip" />
5+
</packages>

docker-compose.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
version: '2'
2+
services:
3+
flask:
4+
restart: always
5+
build: .
6+
ports:
7+
- "5000:5000"
8+
volumes:
9+
- .:/code

requirements.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Flask>=0.10.1
2+
itsdangerous>=0.24
3+
Jinja2>=2.8
4+
MarkupSafe>=0.23
5+
Werkzeug>=0.11.4

0 commit comments

Comments
 (0)