pip install virtualenv 여러군데 공유하고 작업할 수 있게 기능을 터미널을 이용해 깔아줌
virtualenv env
액티베이트 환경 설정
\env\Scripts\activate.bat
어우 이거 안되어가지고는 스택오버플로우 당근찾아줌

다음. fpip3 install flask flask-sqlalchemy 쳐줌
플라스크가깔아짐
body{
margin :0;
font-family : sans-serif;
}
{% extends 'base.html' %}
{% block head %}
{% endblock%}
{% block body %}
<h1>Template</h1>
{% endblock %}
진자 활용하여 css파일 링크연결
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel ="stylesheet" href = "{{ url_for('static',filename='css/') }}"
{% block head %}{% endblock%}
</head>
<body>
{% block body %}{% endblock%}
</body>
</html>
pip3 install flask-SQLAlchemy

from flask import Flask , render_template ,url_for,request
from flask_sqlalchemy import SQLAlchemy
from datetime import datetime
from sqlalchemy.orm import exc
from werkzeug.utils import redirect
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI' ]= 'sqlite:///test.db'
db = SQLAlchemy(app)
db.create_all()
class Todo(db.Model):
id = db.Column(db.Integer,primary_key = True)
content = db.Column(db.String(200), nullable = False)
date_created = db.Column(db.DateTime,default = datetime.utcnow)
def __repr__(self):
return '<Task %r>' % self.id
@app.route('/', methods = ['POST','GET'])
def index():
if request.method == 'POST':
task_content = request.form['content']
new_task = Todo(content = task_content)
try:
db.session.add(new_task)
db.session.commit()
return redirect('/')
except:
return 'There was an issue adding your task'
else:
tasks = Todo.query.order_by(Todo.date_created).all()
return render_template('index.html', tasks = tasks)
@app.route('/delete/<int:id>')
def delete(id):
task_to_delete = Todo.query.get_or_404(id)
try:
db.session.delete(task_to_delete)
db.session.commit()
return redirect('/')
except:
return 'There was a problem deleting that task'
@app.route('/update/<int:id>', methods=['GET', 'POST'])
def update(id):
task = Todo.query.get_or_404(id)
if request.method == 'POST':
task.content = request.form['content']
try:
db.session.commit()
return redirect('/')
except:
return 'There was an issue updating your task'
else:
return render_template('update.html', task=task)
if __name__ == "__main__":
app.run(debug=True,host ='0.0.0.0',port = 5000)

gce오류난거 해결
sudo apt-get install python-setuptools python-dev build-essential
sudo easy_install pip
sudo pip install flask
sudo python app.py
순서대로 쳐 주면 끝:)
GCP Flask 배포
일단은 GCP 콘솔로 들어갑니다. https://console.cloud.google.com/home/dashboard?hl=ko&project=evocative-lodge-266710 Google Cloud Platform 하나의 계정으로 모든 Google 서비스를 Google Cloud Platform을..
philosopher-chan.tistory.com
'✍2021,2022 > 클라우드' 카테고리의 다른 글
kibana (0) | 2022.08.11 |
---|---|
ELK-2(ElasticSearch) (0) | 2022.08.09 |
ELK -DAY1 (0) | 2022.08.08 |
도커 공부 (0) | 2022.01.16 |
클라우드 부트캠프 - (1) (0) | 2022.01.08 |
pip install virtualenv 여러군데 공유하고 작업할 수 있게 기능을 터미널을 이용해 깔아줌
virtualenv env
액티베이트 환경 설정
\env\Scripts\activate.bat
어우 이거 안되어가지고는 스택오버플로우 당근찾아줌

다음. fpip3 install flask flask-sqlalchemy 쳐줌
플라스크가깔아짐
body{
margin :0;
font-family : sans-serif;
}
{% extends 'base.html' %}
{% block head %}
{% endblock%}
{% block body %}
<h1>Template</h1>
{% endblock %}
진자 활용하여 css파일 링크연결
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel ="stylesheet" href = "{{ url_for('static',filename='css/') }}"
{% block head %}{% endblock%}
</head>
<body>
{% block body %}{% endblock%}
</body>
</html>
pip3 install flask-SQLAlchemy

from flask import Flask , render_template ,url_for,request
from flask_sqlalchemy import SQLAlchemy
from datetime import datetime
from sqlalchemy.orm import exc
from werkzeug.utils import redirect
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI' ]= 'sqlite:///test.db'
db = SQLAlchemy(app)
db.create_all()
class Todo(db.Model):
id = db.Column(db.Integer,primary_key = True)
content = db.Column(db.String(200), nullable = False)
date_created = db.Column(db.DateTime,default = datetime.utcnow)
def __repr__(self):
return '<Task %r>' % self.id
@app.route('/', methods = ['POST','GET'])
def index():
if request.method == 'POST':
task_content = request.form['content']
new_task = Todo(content = task_content)
try:
db.session.add(new_task)
db.session.commit()
return redirect('/')
except:
return 'There was an issue adding your task'
else:
tasks = Todo.query.order_by(Todo.date_created).all()
return render_template('index.html', tasks = tasks)
@app.route('/delete/<int:id>')
def delete(id):
task_to_delete = Todo.query.get_or_404(id)
try:
db.session.delete(task_to_delete)
db.session.commit()
return redirect('/')
except:
return 'There was a problem deleting that task'
@app.route('/update/<int:id>', methods=['GET', 'POST'])
def update(id):
task = Todo.query.get_or_404(id)
if request.method == 'POST':
task.content = request.form['content']
try:
db.session.commit()
return redirect('/')
except:
return 'There was an issue updating your task'
else:
return render_template('update.html', task=task)
if __name__ == "__main__":
app.run(debug=True,host ='0.0.0.0',port = 5000)

gce오류난거 해결
sudo apt-get install python-setuptools python-dev build-essential
sudo easy_install pip
sudo pip install flask
sudo python app.py
순서대로 쳐 주면 끝:)
GCP Flask 배포
일단은 GCP 콘솔로 들어갑니다. https://console.cloud.google.com/home/dashboard?hl=ko&project=evocative-lodge-266710 Google Cloud Platform 하나의 계정으로 모든 Google 서비스를 Google Cloud Platform을..
philosopher-chan.tistory.com
'✍2021,2022 > 클라우드' 카테고리의 다른 글
kibana (0) | 2022.08.11 |
---|---|
ELK-2(ElasticSearch) (0) | 2022.08.09 |
ELK -DAY1 (0) | 2022.08.08 |
도커 공부 (0) | 2022.01.16 |
클라우드 부트캠프 - (1) (0) | 2022.01.08 |