-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmicroservice.py
40 lines (29 loc) · 992 Bytes
/
microservice.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# This Python file uses the following encoding: utf-8
import os
import json
from bottle import route, run, debug, template, request, response, static_file, error, hook, BaseRequest, Bottle
import requests
import random
from time import time
BaseRequest.MEMFILE_MAX = 10000000000 # (or whatever you want)
app = Bottle()
# Add JSON endpoint headers
@app.hook('before_request')
def enable_cors():
response.headers['Access-Control-Allow-Origin'] = '*'
response.headers["Content-type"] = "application/json"
@app.route("/")
def index():
response.headers["Content-type"] = "text/html"
return template("html_pages/index.html")
@app.route("/html/<filepath:re:.*\.html>")
def html(filepath):
return static_file(filepath,root="html_pages/")
@app.route("/css/<filepath:re:.*\.css>")
def css(filepath):
return static_file(filepath,root="css/")
@app.route("/js/<filepath:re:.*\.js>")
def js(filepath):
return static_file(filepath,root="js/")
debug(True)
app.run(host='0.0.0.0',port=1200)