1. flask 예제 (http)
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello():
return '<h1>This is HTTP site</h1>'
if __name__ == '__main__':
app.run('0.0.0.0', 9999, debug=True)
2. 인증서 생성
openssl req -x509 -newkey rsa:4096 -nodes -out cert.pem -keyout key.pem -days 365
3. flask 예제 (https)
from flask import Flask
import eventlet
import eventlet.wsgi
app = Flask(__name__)
@app.route('/')
def hello():
return '<h1>This is HTTPS site</h1>'
if __name__ == '__main__':
server = eventlet.wrap_ssl(eventlet.listen(('0.0.0.0', 9999)), certfile='secrets/cert.pem', keyfile='secrets/key.pem', server_side=True)
eventlet.wsgi.server(server, app)