This is the 4th day article of Advent Calender on the 2019 code-server. This time as well, I will explain what is code-server?
(1) What is code-server? (2) Create your own code-server environment with Docker (3) Try using VSCode Plugin (4) Let's prepare an MVC environment including DB etc. (1) (5) Let's prepare an MVC environment including DB etc. (2) (6) Let's prepare an MVC environment including DB etc. (3) (7) Let's prepare an MVC environment including DB etc. (4) (8) Let's prepare an MVC environment including DB etc. (5) (9) Let's prepare an MVC environment including DB etc. (6) (10) Bonus
(NEXT->) Online environment version 1st day Improve the work environment
(..) To build locally including environment such as DB (..) How to put it online? (..) How to work with the latest trendy environment such as K8S? (..) I want to modify Code-Server to make it better
Continuing from the last time, let's run flask.
Since it is VSCode, you can use Terminal. You can operate Linux with cli. So, you can launch ssh separately
dockeer-compose exec -it app bash
There is no need to launch Terminal separately. I'm using bash, so first
bash
I am trying to enter.
A lightweight web framework. You can create a web page very easily.
https://github.com/pallets/flask
I will try it for the first time from the continuation of the last time.
Create requirements.txt.
requirements.txt
flask
On the command line
pip install -r requirements.txt
Let's write the code.
main.py
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello, World!"
app.run("0.0.0.0",port=8080)
Let's do it !!
$ python main.py
* Serving Flask app "main" (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off
* Running on http://0.0.0.0:8080/ (Press CTRL+C to quit)
When I open http://127.0.0.1:8080/ in a browser, it says Hello, World!
Let's create a db environment
PS
https://github.com/kyorohiro/advent-2019-code-server
Recommended Posts