-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp_Ud
More file actions
65 lines (56 loc) · 1.92 KB
/
Copy pathApp_Ud
File metadata and controls
65 lines (56 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#https://c9.io/parthasen (parthasen,parthasen2012)
#workspace
cd flask_ud_ubuntu#https://ide.c9.io/parthasen/flask_ud_ubuntu#openfile-README.md
#folder
cd flask_init
sudo apt-get install Python3 # needed as python2 is default
sudo pip install virtualenv # needed if virtualenv command is not loaded
virtualenv -p python3 venv # virtual environment created
source venv/bin/activate
deactivate
python -V
#Setting PATH
flask_init>lib>site packages <- right click >new terminal>pwd>copy path>gear>languages support>PYTHONPATH>paste after :
#AWS
https://medium.com/@rodkey/deploying-a-flask-application-on-aws-a72daba6bb80#.munjrwpnm
https://www.youtube.com/watch?v=3HuYr6G2Z28
***
import os
from flask import Flask,url_for,request
app = Flask(__name__)
@app.route('/index')
def index():
return "index page"
@app.route('/')
def index_user():
return url_for('show_user_profile',username='parthasen')
@app.route('/user/<username>')
def show_user_profile(username):
return "user %s"% username
@app.route('/post/<int:post_id>')
def show_post(post_id):
return "post %d" % post_id
'''
@app.route('/login_get',methods=['GET'])
def login_get():
if request.values:
return 'username is %s' + request.values['username']
else:
return '<form method="get" action="/login"><input type="text" name="username" /><p><button type="subWWWmit">Submit</button></form>'
'''
@app.route('/log', methods=['GET','POST'])
def login():
if request.method=='POST':
return 'username is %s' + request.values['username']
else:
return '<form method="post" action="/login"><input type="text" name="username" /><p><button type="subWWWmit">Submit</button></form>'
@app.route('/hello')
def hello_world():
i=1
i=i+1
return "Hello visits %s" % i + "times"
if __name__=="__main__":
host=os.getenv('IP','0.0.0.0')
port = int(os.getenv('PORT',5000))
app.debug=True
app.run(host=host,port=port,debug=True)