Commit 509cc232 authored by Christian Elberfeld's avatar Christian Elberfeld

Initial implementation with Dummy Status

parent 91c8124c
FROM debian:stretch
# Python Packages
RUN apt-get update && apt-get install -y \
python3 \
python3-pip
# Upgrade pip
RUN pip3 install --upgrade pip
# pip Packages
RUN pip3 install \
flask==1.0.2 \
pytz \
uwsgi \
--upgrade
# start Script
COPY entrypoint_dev.sh /opt/entrypoint_dev.sh
COPY entrypoint_prod.sh /opt/entrypoint_prod.sh
RUN chmod +x /opt/entrypoint*
EXPOSE 5000
VOLUME ["/opt/warpapi"]
CMD ["/opt/entrypoint_prod.sh"]
# warpapi
# SpaceAPI Implementierung
Verfügbar unter https://api.warpzone.ms
Eigenständuge und kompakte Reimplementierung der SpaceAPI als eigenständige Flask Applikation
Die Standard SpaceAPI wird unter /spaceapi bereitgestellt.
Für die Einbindung auf cpu.ccc.de ist /cccapi vorgesehen.
version: "3"
services:
app:
build: .
ports:
- 0.0.0.0:5000:5000
volumes:
- ./warpapi/:/opt/warpapi
#!/bin/bash
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
export FLASK_APP=warpapi.py
export FLASK_ENV=development
cd /opt/warpapi/
flask run --host=0.0.0.0
#!/bin/bash
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
export FLASK_APP=warpapi.py
export FLASK_ENV=production
cd /opt/warpapi/
uwsgi --uid=www-data --gid=www-data --socket 0.0.0.0:5000 --protocol=http -w wsgi:app
docker kill warpapi
docker rm warpapi
docker rmi warpapi
docker build . -t warpapi
docker run -v %cd%/warpapi:/opt/warpapi -p 5000:5000 --name warpapi -it warpapi /opt/entrypoint_dev.sh
docker kill warpapi
docker rm warpapi
docker rmi warpapi
docker build . -t warpapi
docker run -v %cd%/warpapi:/opt/warpapi -p 5000:5000 --name warpapi -it warpapi
import datetime
import pytz
from flask import Flask
from flask import request
from flask import redirect
from flask import send_from_directory
from flask import json
app = Flask(__name__, static_url_path='')
if __name__ == "__main__":
app.run()
@app.route('/')
def hello_world():
return 'Warpzone API'
@app.route('/static/<path:path>')
def send_static(path):
return send_from_directory('static', path)
@app.route('/cccapi')
def cccapi():
return redirect('/spaceapi', code=302)
@app.route('/spaceapi')
def spaceapi():
spaceopen = False
now = datetime.datetime.now(pytz.timezone('Europe/Berlin'))
dayofweek = now.strftime("%w")
# Hardcode Mittwoch Abend offen
if dayofweek == "3":
if now.hour >= 18:
spaceopen = True
# Hardcode Samstag Abend offen
if dayofweek == "6":
if now.hour >= 18:
spaceopen = True
data = {
"api": "0.13",
"space": "warpzone ",
"logo": "https://api.warpzone.ms/static/warpzone_logo.png",
"url": "https://www.warpzone.ms",
"location": {
"address": "warpzone e.V., Am Hawerkamp 31 Maus G, 48155 Münster, Germany",
"lat": "51.943376",
"lon": "7.638216",
},
"contact": {
"phone": "+49 251 39500271",
"twitter": "@warpzone_ms",
"email": "office@warpzone.ms",
"irc": "irc://irc.freenode.net/#warpzone",
"ml": "warpzone@warpzone.ms",
},
"issue_report_channels": [
"email"
],
"feeds": {
"blog": {
"type": "application/rss+xml",
"url": "https://www.warpzone.ms/feed/",
},
"calendar": {
"type": "application/calendar",
"url": "https://www.google.com/calendar/ical/hc82sdjshuf1ru9f9eqcfq9bvs%40group.calendar.google.com/public/basic.ics",
},
},
"state": {
"open": spaceopen,
"icon": {
"open": "https://api.warpzone.ms/static/warpzone_open.png",
"closed": "https://api.warpzone.ms/static/warpzone_closed.png",
},
},
}
response = app.response_class(
response=json.dumps(data),
status=200,
mimetype='application/json'
)
return response
from warpapi import app
if __name__ == "__main__":
app.run()
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment