python sleep type function
This commit is contained in:
parent
b64c75f162
commit
60926a3af1
6
sleep-python/.dockerignore
Normal file
6
sleep-python/.dockerignore
Normal file
@ -0,0 +1,6 @@
|
||||
Dockerfile
|
||||
README.md
|
||||
*.pyc
|
||||
*.pyo
|
||||
*.pyd
|
||||
__pycache__
|
2
sleep-python/.idea/.gitignore
vendored
Normal file
2
sleep-python/.idea/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
# Default ignored files
|
||||
/workspace.xml
|
@ -0,0 +1,6 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<settings>
|
||||
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||
<version value="1.0" />
|
||||
</settings>
|
||||
</component>
|
20
sleep-python/.idea/isprime-python.iml
Normal file
20
sleep-python/.idea/isprime-python.iml
Normal file
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="Flask">
|
||||
<option name="enabled" value="true" />
|
||||
</component>
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="R User Library" level="project" />
|
||||
<orderEntry type="library" name="R Skeletons" level="application" />
|
||||
</component>
|
||||
<component name="TemplatesService">
|
||||
<option name="TEMPLATE_CONFIGURATION" value="Jinja2" />
|
||||
</component>
|
||||
<component name="TestRunnerService">
|
||||
<option name="projectConfiguration" value="pytest" />
|
||||
<option name="PROJECT_TEST_RUNNER" value="pytest" />
|
||||
</component>
|
||||
</module>
|
6
sleep-python/.idea/libraries/R_User_Library.xml
Normal file
6
sleep-python/.idea/libraries/R_User_Library.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<component name="libraryTable">
|
||||
<library name="R User Library">
|
||||
<CLASSES />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</component>
|
7
sleep-python/.idea/misc.xml
Normal file
7
sleep-python/.idea/misc.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="JavaScriptSettings">
|
||||
<option name="languageLevel" value="ES6" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7" project-jdk-type="Python SDK" />
|
||||
</project>
|
8
sleep-python/.idea/modules.xml
Normal file
8
sleep-python/.idea/modules.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/isprime-python.iml" filepath="$PROJECT_DIR$/.idea/isprime-python.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
6
sleep-python/.idea/vcs.xml
Normal file
6
sleep-python/.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||
</component>
|
||||
</project>
|
17
sleep-python/Dockerfile
Normal file
17
sleep-python/Dockerfile
Normal file
@ -0,0 +1,17 @@
|
||||
# Use the official lightweight Python image.
|
||||
# https://hub.docker.com/_/python
|
||||
FROM python:3.7-slim
|
||||
|
||||
# Copy local code to the container image.
|
||||
ENV APP_HOME /app
|
||||
WORKDIR $APP_HOME
|
||||
|
||||
# Install production dependencies.
|
||||
RUN pip install --no-cache-dir Flask gunicorn
|
||||
|
||||
COPY . ./
|
||||
# Run the web service on container startup. Here we use the gunicorn
|
||||
# webserver, with one worker process and 8 threads.
|
||||
# For environments with multiple CPU cores, increase the number of workers
|
||||
# to be equal to the cores available.
|
||||
CMD exec gunicorn --bind :$PORT --workers 1 --threads 1 app:app
|
19
sleep-python/app.py
Normal file
19
sleep-python/app.py
Normal file
@ -0,0 +1,19 @@
|
||||
import os
|
||||
import time
|
||||
from flask import Flask
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
def safe_cast(val, to_type, default=107107):
|
||||
try:
|
||||
return to_type(val)
|
||||
except (ValueError, TypeError):
|
||||
return default
|
||||
|
||||
@app.route('/')
|
||||
def sleeper():
|
||||
time.sleep(0.1)
|
||||
return "Slept well"
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run(debug=True,host='0.0.0.0',port=int(os.environ.get('PORT', 8080)))
|
Loading…
Reference in New Issue
Block a user