This file contains hidden or 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
val file = spark.textFile("hdfs://...") | |
val counts = file.flatMap(line => line.split(" ")) | |
.map(word => (word, 1)) | |
.reduceByKey(_ + _) | |
counts.saveAsTextFile("hdfs://...") |
This file contains hidden or 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
@app.route("/mypage/<id>") | |
@jwt_required(scope='admin') | |
def mypage(id): | |
... |
This file contains hidden or 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
# GET /jobs/application/6337 | |
@app.route(/jobs/application/<job_id>) | |
def find_job(job_id): | |
SELECT * FROM job where id = job_id ... | |
# ๋์๋ฐฉ์์ผ๋ก๋ `Flask-Login` ๋ฑ์ ์ฌ์ฉํ์ฌ ๊ฐ์ ์ฐธ์กฐํ๋ ๋ฐฉ๋ฒ์ด ์์ต๋๋ค. | |
from flask.ext.login import login_required, current_user | |
@app.route("/mypage/<id>") |
This file contains hidden or 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
@app.route('/hi/<user>') | |
def hi(user): | |
return "<h1>hello, %s!</h1>"%user | |
# ์์ ๊ฐ์ ๊ฐ๋จํ ๋ผ์ฐํ ์์ ์๋์ ๊ฐ์ด ๊ณต๊ฒฉํ ์ ์์ต๋๋ค. | |
# GET /hi/alert("hacked!") | |
# <h1> hello, alert("hacked!") </h1> | |
# ์ด๊ฑธ ๋ณธ ์ ์ ๋ javascript alert์ฐฝ์ด ๋ํ๋๋ค |
This file contains hidden or 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
@app.route("/user/<user_id>") | |
def show_user(user_id): | |
cur = db.cursor() | |
query = "SELECT * FROM user_table where user = %s"%user_id | |
c.execute(query) | |
return c.fetchall() |
This file contains hidden or 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
<!-- ๋ฒํผ์ด๋ input์ ์ ์ถํ๋ฉด ์ฃผ์์ด ํ๋ฆฐ๋ค! --> | |
<form action='/stock/sell' method='get'> | |
<input type=submit value=sell_stock> | |
</form> | |
<a href="/stock/sell/"> click me!</a> | |
<form action='/stock/sell' method='post'> | |
<input type=submit value=sell_stock> | |
</form> | |
<!-- ํ๋ผ์คํฌ์์๋ `Flask-WTF` ํจํค์ง๋ฅผ ํตํด ์ ๋ ฅ ํผ์ ๊ฒ์ฆํ๊ณ CSRF๋ฅผ ๋ฐฉ์ง๊ฐ๋ฅ --> |
This file contains hidden or 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
def save_db(df, table): | |
try: | |
engine = create_engine("mysql+mysqldb://root:"+"password"+"@localhost/"+table, encoding='utf-8') | |
conn = engine.connect() | |
# Save dataframe to database | |
df.to_sql(name=table, con=engine, if_exists='append') | |
print("Saved successfully!!") | |
except: |
This file contains hidden or 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
public class test { | |
private int test; | |
} |
NewerOlder