[PYTHON] Try to make a web service-like guy with 3D markup language

Purpose

Create a Web system that dynamically outputs the 3D markup language up to the last time.

Tool stand

I'm relatively used to it, so I'll try to make it quickly using Flask in Python.

Make a clock

Since it is a large scale to access the database and use the API, I will try to make a clock that displays the access time as a minimum as PoC. Below is a program that displays the spheres that correspond to the hours, minutes, and seconds. It does not move with the passage of time.

app.py


from flask import Flask
import datetime
import math

app = Flask(__name__)

@app.route('/')
def clock():
    dt_now = datetime.datetime.now()

    hour = dt_now.hour % 12
    minute = dt_now.minute
    sec = dt_now.second

    yh = 0.2 * math.cos(hour * 2 * 3.141592 / 12)
    xh = 0.2 * math.sin(hour * 2 * 3.141592 / 12)
    ym = 0.4 * math.cos(minute * 2 * 3.141592 / 60)
    xm = 0.4 * math.sin(minute * 2 * 3.141592 / 60)
    ys = 0.35 * math.cos(sec * 2 * 3.141592 / 60)
    xs = 0.35 * math.sin(sec * 2 * 3.141592 / 60)

    homl = '''<homl><head><title>CLOCK</title></head>
<body><a-scene wx=0.2 wy=0.2 wz=0.2>
<a-sphere r=0.05 x=0 y=0 z=0 color=white />
<a-sphere r=0.05 x={xh} y={yh} z=0 color=red />
<a-sphere r=0.03 x={xm} y={ym} z=0 color=green />
<a-sphere r=0.01 x={xs} y={ys} z=0 color=blue />
</a-scene></body></homl>
'''.format(xh=xh,yh=yh,xm=xm,ym=ym,xs=xs,ys=ys)

    return homl

if __name__ == '__main__':
    app.run()

result

20191223_homl_clock.PNG

It became like that. Now the world of the Internet and the world of XR are easily connected.

Recommended Posts

Try to make a web service-like guy with 3D markup language
Try to make a "cryptanalysis" cipher with Python
Try to make a dihedral group with Python
Try to make a Python module in C language
Try to make a command standby tool with python
WEB scraping with python and try to make a word cloud from reviews
Try to select a language
Try to make a kernel of Jupyter
Let's make a simple language with PLY 1
I tried to make a Web API
Let's make a web framework with Python! (1)
Let's make a web framework with Python! (2)
Try to make a capture software with as high accuracy as possible with python (2)
I came up with a way to make a 3D model from a photo.
A memorandum to make WebDAV only with nginx
How to make a dictionary with a hierarchical structure.
I want to make a game with Python
Try to make client FTP fastest with Pythonista
(Memorandum) Make a 3D scatter plot with matplodlib
Lark Basics (Python, Lark to make a shell-like guy)
[Practice] Make a Watson app with Python! # 1 [Language discrimination]
Try to operate DB with Python and visualize with d3
How to make a shooting game with toio (Part 1)
Try to make RESTful API with MVC using Flask 1.0.2
[GCP] Try a sample to authenticate users with Firebase
Make a function to describe Japanese fonts with OpenCV
I came up with a way to make a 3D model from a photo. 0 Projection to 3D space
A sample to try Factorization Machines quickly with fastFM
Machine learning beginners try to make a decision tree
Beginners try to make an online battle Othello web application with Django + React + Bootstrap (1)
How to make a 3D geometric figure with one click [From triangular pyramid to fractal]
[Python] How to create a 2D histogram with Matplotlib
Deploy a web app created with Streamlit to Heroku
[Python] I want to make a 3D scatter plot of the epicenter with Cartopy + Matplotlib!
I tried to make a motion detection surveillance camera with OpenCV using a WEB camera with Raspberry Pi
How to deploy a web app made with Flask to Heroku
How to make a Cisco Webex Teams BOT with Flask
[Practice] Make a Watson app with Python! # 3 [Natural language classification]
[Go language] Try to create a uselessly multi-threaded line counter
I want to make a blog editor with django admin
Experiment to make a self-catering PDF for Kindle with Python
I want to make a click macro with pyautogui (desire)
How to make a simple Flappy Bird game with pygame
I want to make a click macro with pyautogui (outlook)
Try to bring up a subwindow with PyQt5 and Python
Make a 2D RPG with Ren'Py (3) -Items and Tool Shop
(For beginners) Try creating a simple web API with Django
[Introduction to Tensorflow] Understand Tensorflow properly and try to make a model
Try HeloWorld in your own language (with How to & code)
I tried to divide with a deep learning language model
Try to factorial with recursion
Easy to make with syntax
Make a fortune with Python
If you try to make a word cloud with comments from WEB manga, it is interesting to visually understand what kind of manga it is.
Make a fire with kdeplot
Tokyo Corona: Try to make a simple prediction from open data with the exponential function curve_fit
I tried to easily create a high-precision 3D image with one photo [2]. (Try processing depth with numpy)
[5th] I tried to make a certain authenticator-like tool with python
[C language] [Linux] Try to create a simple Linux command * Just add! !!
If you know Python, you can make a web application with Django
Let's make a WEB application for phone book with flask Part 1