changing server to use flask
This commit is contained in:
18
.vscode/launch.json
vendored
18
.vscode/launch.json
vendored
@@ -5,11 +5,23 @@
|
|||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"name": "Launch Server",
|
"name": "Python: Flask",
|
||||||
"type": "python",
|
"type": "python",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"program": "${workspaceFolder}/server.py",
|
"module": "flask",
|
||||||
"console": "integratedTerminal"
|
"env": {
|
||||||
|
"FLASK_APP": "app.py",
|
||||||
|
"FLASK_ENV": "development",
|
||||||
|
"FLASK_DEBUG": "0"
|
||||||
|
},
|
||||||
|
"args": [
|
||||||
|
"run",
|
||||||
|
"--host","0.0.0.0",
|
||||||
|
"--port","9000",
|
||||||
|
"--no-debugger",
|
||||||
|
"--no-reload"
|
||||||
|
],
|
||||||
|
"jinja": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"python.jediEnabled": false
|
|
||||||
}
|
|
||||||
10
README.md
10
README.md
@@ -15,15 +15,15 @@ Some things to try:
|
|||||||
2. Try adding some code and check out the language features.
|
2. Try adding some code and check out the language features.
|
||||||
2. **Terminal:** Press <kbd>ctrl</kbd>+<kbd>shift</kbd>+<kbd>\`</kbd> and type `uname` and or other Linux commands from the terminal window.
|
2. **Terminal:** Press <kbd>ctrl</kbd>+<kbd>shift</kbd>+<kbd>\`</kbd> and type `uname` and or other Linux commands from the terminal window.
|
||||||
3. **Build, Run, and Debug:**
|
3. **Build, Run, and Debug:**
|
||||||
1. Open `sever.py`
|
1. Open `app.py`
|
||||||
2. Add a breakpoint (e.g. on line 13).
|
2. Add a breakpoint (e.g. on line 9).
|
||||||
3. Press <kbd>F5</kbd> to launch the app in the container.
|
3. Press <kbd>F5</kbd> to launch the app in the container.
|
||||||
4. Once the breakpoint is hit, try hovering over variables, examining locals, and more.
|
4. Once the breakpoint is hit, try hovering over variables (e.g. the app variable on line 7), examining locals, and more.
|
||||||
5. Continue, then open a local browser and go to `http://localhost:9000` and note you can connect to the server in the container
|
5. Continue, then open a local browser and go to `http://localhost:9000` and note you can connect to the server in the container
|
||||||
4. **Forward another port:**
|
4. **Forward another port:**
|
||||||
1. Stop debugging and remove the breakpoint.
|
1. Stop debugging and remove the breakpoint.
|
||||||
2. Open `sever.py`
|
2. Open `.vscode/launch.json`
|
||||||
3. Change the server port to 5000. (`PORT = 5000`)
|
3. Change the server port to 5000 on line 20. (`"--port","5000"`)
|
||||||
4. Press <kbd>F5</kbd> to launch the app in the container.
|
4. Press <kbd>F5</kbd> to launch the app in the container.
|
||||||
5. Press <kbd>F1</kbd> and run the **Remote-Containers: Forward Port...** command.
|
5. Press <kbd>F1</kbd> and run the **Remote-Containers: Forward Port...** command.
|
||||||
6. Select port 5000.
|
6. Select port 5000.
|
||||||
|
|||||||
@@ -3,13 +3,9 @@
|
|||||||
# Licensed under the MIT License. See LICENSE in the project root for license information.
|
# Licensed under the MIT License. See LICENSE in the project root for license information.
|
||||||
#-----------------------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------------------
|
||||||
|
|
||||||
import socketserver
|
from flask import Flask
|
||||||
import http.server
|
app = Flask(__name__)
|
||||||
|
|
||||||
RequestHandler = http.server.SimpleHTTPRequestHandler
|
@app.route("/")
|
||||||
|
def hello():
|
||||||
PORT = 5000
|
return app.send_static_file("index.html")
|
||||||
|
|
||||||
with socketserver.TCPServer(("", PORT), RequestHandler) as httpd:
|
|
||||||
print("Server running on port", PORT)
|
|
||||||
httpd.serve_forever()
|
|
||||||
1
requirements.txt
Normal file
1
requirements.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
flask
|
||||||
Reference in New Issue
Block a user