Skip to content

Commit

Permalink
Fix utc-time for new everything
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasHabets committed Jan 17, 2024
1 parent d46a70b commit 52ee28a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
6 changes: 1 addition & 5 deletions utc-time/app.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
application: utc-time2
version: 1
runtime: python27
api_version: 1
threadsafe: false
runtime: python312

handlers:
- url: /.*
Expand Down
29 changes: 20 additions & 9 deletions utc-time/utc-time.py → utc-time/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,24 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# gcloud app deploy --project utc-time2
import time
t = time.time()
u = time.gmtime(t)
s = time.strftime('%a, %e %b %Y %T GMT', u)
print 'Content-Type: text/javascript'
print 'Cache-Control: no-cache'
print 'Date: ' + s
print 'Expires: ' + s
print ''
print 'var timeskew = new Date().getTime() - ' + str(t*1000) + ';'
from flask import Flask, make_response, request
app = Flask(__name__)

@app.route('/')
def root():
t = time.time()
u = time.gmtime(t)
s = time.strftime('%a, %e %b %Y %T GMT', u)

resp = make_response('var timeskew = new Date().getTime() - ' + str(t*1000) + ';')
resp.headers['Content-Type'] = 'text/javascript'
resp.headers['Cache-Control'] = 'no-cache'
resp.headers['Date'] = s
resp.headers['Expires'] = s
return resp

if __name__ == "__main__":
app.run(host="127.0.0.1", port=8080, debug=True)
1 change: 1 addition & 0 deletions utc-time/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Flask==3.0.0

0 comments on commit 52ee28a

Please sign in to comment.