-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
migration to seperate repo from web-microframework
- Loading branch information
0 parents
commit 6a800e5
Showing
8 changed files
with
134 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
brew "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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
FROM python:2-onbuild | ||
|
||
# Create app directory | ||
RUN mkdir -p /usr/src/app | ||
WORKDIR /usr/src/app | ||
|
||
# Install app dependencies | ||
COPY requirements.txt /usr/src/app/ | ||
RUN pip install -r requirements.txt | ||
|
||
# Bundle app source | ||
COPY . /usr/src/app | ||
|
||
EXPOSE 5000 | ||
ENTRYPOINT ["python"] | ||
CMD ["app.py"] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# **Flask WebMF** | ||
|
||
## **Using on Mac OS X Host** | ||
|
||
* Prerequisites: | ||
* Install XCode Command Line Tools | ||
* Install Brew `/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"` | ||
|
||
### **Install** | ||
|
||
```bash | ||
$ brew install python | ||
$ # Install/Setup virtualenv (optional) | ||
$ pip install virtualenv | ||
$ pip install virtualenvwrapper | ||
$ mkdir ${HOME}/.virtualenvs | ||
$ source /usr/local/bin/virtualenvwrapper.sh | ||
``` | ||
|
||
## **Run** | ||
|
||
```bash | ||
$ pip install flask # install flask library | ||
$ ./app.py # run program | ||
``` | ||
|
||
### **Run Using Virtualenv** | ||
|
||
This uses [virtualenv](https://virtualenv.pypa.io/en/latest/), so that libraries are installed in locally in only your account. | ||
|
||
```bash | ||
$ mkvirtualenv flaskenv # create segregated environment | ||
$ pip install -r requirements.txt # install flask library locally | ||
$ ./app.py # run program | ||
$ ## Run Tests Here (see below) | ||
$ deactivate # exit segregated environment | ||
``` | ||
|
||
## **Using Docker or Vagrant** | ||
|
||
See [Tools Readme](../TOOLS.md) for more information on install, setup, and start Docker or Vagrant. | ||
|
||
### **Build and Run with Docker Compose** | ||
|
||
```bash | ||
$ docker-compose up -d | ||
``` | ||
|
||
### **Build and Run with Vagrant** | ||
|
||
```bash | ||
$ vagrant up | ||
``` | ||
|
||
## **Testing Results** | ||
|
||
```bash | ||
$ [ -z ${DOCKER_MACHINE_NAME} ] || WEBSERVER=$(docker-machine ip ${DOCKER_MACHINE_NAME}) | ||
$ WEBSERVER=${WEBSERVER:-localhost} | ||
$ PORT=5000 | ||
$ curl -i ${WEBSERVER}:${PORT} | ||
HTTP/1.0 200 OK | ||
Content-Type: text/html; charset=utf-8 | ||
Content-Length: 13 | ||
Server: Werkzeug/0.11.4 Python/2.7.11 | ||
Date: Sun, 13 Mar 2016 07:02:41 GMT | ||
|
||
Hello World! | ||
``` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# -*- mode: ruby -*- | ||
# vi: set ft=ruby : | ||
|
||
Vagrant.configure(2) do |config| | ||
config.vm.box = "ubuntu/trusty64" | ||
config.vm.network "forwarded_port", guest: 5000, host: 5000 | ||
|
||
config.vm.provision "docker" do |docker| | ||
docker.build_image "/vagrant", args: "-t vagrant/flask-web" | ||
docker.run "vagrant/flask-web" , args: "-p 5000:5000" | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/env python | ||
from flask import Flask | ||
app = Flask(__name__) | ||
|
||
@app.route('/') | ||
@app.route('/hello') # this route is not working | ||
@app.route('/hello/') | ||
def hello_world(): | ||
return 'Hello World!\n' | ||
|
||
@app.route('/hello/<username>') # dynamic route | ||
def hello_user(username): | ||
# show the user profile for that user | ||
return 'Why Hello %s!\n' % username | ||
|
||
if __name__ == '__main__': | ||
app.run(host='0.0.0.0') # open for everyone |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="python2" /> | ||
<package id="pip" /> | ||
</packages> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
version: '2' | ||
services: | ||
flask: | ||
restart: always | ||
build: . | ||
ports: | ||
- "5000:5000" | ||
volumes: | ||
- .:/code |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Flask>=0.10.1 | ||
itsdangerous>=0.24 | ||
Jinja2>=2.8 | ||
MarkupSafe>=0.23 | ||
Werkzeug>=0.11.4 |