def main() 이 없으니까

독립적으로 실행중인지, import 되어 다른데서 실행을 하는건지 알 필요가 있을때

아래의 문구를 통해서 실행하거나 라이브러리로 작동시키거나 할 수 있다.

if __name__ == "__main__":
    print("run!")

 

[링크 : https://dev-jy.tistory.com/14]

Posted by 구차니

gpt와 검색을 버무려서~

 

pip로 대~~~충 flask 설치하고

Flask 에 static_url_path와 static_folder 를 설정해서 정적으로 서빙할 경로를 지정한다.

template_folder는 template engine를 위한 경로 같긴한데, 지금은 그걸 하려는게 아니니 패스~ 하고

 

/ 로 요청이 들어오면 index.html을 던지도록 라우터 하나 설정하고

나머지는 자동으로 static 경로 하위에서 제공

그리고 /api 쪽은 별도로 라우터 지정해서 2개의 api를 생성해준다.

 

/app.py

from flask import Flask, jsonify, render_template

app = Flask(__name__,
            static_url_path='', 
            static_folder='static',
            template_folder='templates')

@app.route('/')
def serve_index():
    return app.send_static_file('index.html')

# REST API 라우트
@app.route('/api/hello')
def api_hello():
    return jsonify({"message": "Hello, this is a REST API response!"})

# 또 다른 REST API
@app.route('/api/sum/<int:a>/<int:b>')
def api_sum(a, b):
    return jsonify({"a": a, "b": b, "sum": a + b})


if __name__ == "__main__":
    # 디버그 모드 실행
    app.run(debug=True)

 

/static/index.html

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Flask Static + REST API</title>
    <link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
</head>
<body>
    <h1>Hello Flask</h1>
    <p>이 페이지는 Flask가 제공하는 정적 웹입니다.</p>

    <button onclick="callApi()">API 호출</button>
    <p id="result"></p>

    <script>
        async function callApi() {
            const res = await fetch("/api/hello");
            const data = await res.json();
            document.getElementById("result").innerText = data.message;
        }
    </script>
</body>
</html>

 

/static/test.html

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Flask Static + REST API</title>
    <link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
</head>
<body>
    <h1>this is test</h1>
</body>
</html>

 

/static/style.css

body {
    font-family: sans-serif;
    background: #f0f0f0;
    padding: 20px;
}
h1 {
    color: darkblue;
}

 

[링크 : https://stackoverflow.com/questions/20646822/how-to-serve-static-files-in-flask]

 

 

$ python3 app.py
 * Serving Flask app 'app'
 * Debug mode: on
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
 * Running on http://127.0.0.1:5000
Press CTRL+C to quit
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 997-788-229

 

웹에서 접속하면 아래처럼 뜨는데

보니 template 엔진을 이용해서 치환하도록 해놨어서 css가 안 읽혔군

127.0.0.1 - - [29/Sep/2025 10:48:26] "GET / HTTP/1.1" 304 -
127.0.0.1 - - [29/Sep/2025 10:48:26] "GET /{{%20url_for('static',%20filename='style.css')%20}} HTTP/1.1" 404 -

 

그럼 template 안쓸꺼니 수정해보자

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Flask Static + REST API</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <h1>Hello Flask</h1>
    <p>이 페이지는 Flask가 제공하는 정적 웹입니다.</p>

    <button onclick="callApi()">API 호출</button>
    <p id="result"></p>

    <script>
        async function callApi() {
            const res = await fetch("/api/hello");
            const data = await res.json();
            document.getElementById("result").innerText = data.message;
        }
    </script>
</body>
</html>

 

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Flask Static + REST API</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <h1>this is test</h1>
</body>
</html>

 

이쁘게 잘나온다. 그런데 처음 접속하면 static web이라도 제법 느린데 캐싱이 안되나?

 

localhost:5000/

localhost:5000/index.html

localhost:5000/test.html

localhost:5000/api/hello

localhost:5000/api/sum/2/3

'Programming > python(파이썬)' 카테고리의 다른 글

python switch-case -> match-case  (0) 2025.10.11
python __name__  (0) 2025.09.29
python simsimd  (0) 2025.08.28
python 원하는 버전 설치 및 연결하기  (0) 2025.08.26
pip 패키지 완전 삭제하기  (0) 2025.08.13
Posted by 구차니

게임내에서 제공되는 텔레메트리 정보인데

프로토콜에서 제공되는 내용보다 더 다양한거 같다?

켜놓으면 재미있긴 한데 지도가 사라져서 아쉽..

 

없어 보이는 데이터로는

손상 /  타이어 온도 / 타이어 정보(압력)

 

여기부터는 udp telemetry에 있는 값들 같다.

Posted by 구차니
게임2025. 9. 27. 22:46

이 게임을 구매했던 가장 큰 이유!

오로라를 보고 싶어서!!

 

오늘 설치하고

레고 에서 빠져나와서

미션 몇 개 하다가

산장 하나 구매하고

버기 탔더니

갑자기 계절이 바뀌더니

먼가 갑자기 열려서 고고!

 

아 오로라 만세!

 

'게임' 카테고리의 다른 글

forza horizon 4 - 가을시즌 획득!  (0) 2024.11.24
flight simulator X  (0) 2021.06.27
magicka chapter 9 포기 -_ㅠ  (0) 2020.04.01
magicka 포기?  (0) 2020.03.30
magicka 챕터 4까지 완료!  (0) 2020.03.21
Posted by 구차니

dvb 재생등을 위해 마우스 이벤트를 처리할 수 있을 것 같은데

navigationtest 라는 엘리먼트는 보이는데 이게 gstnavigation과 같은건가 확신이 안선다.

 

[링크 : https://gstreamer.freedesktop.org/documentation/video/gstnavigation.html?gi-language=c]

[링크 : https://gstreamer.freedesktop.org/documentation/plugin-development/advanced/events.html?gi-language=c]

[링크 : https://gstreamer.freedesktop.org/documentation/navigationtest/index.html?gi-language=c]

'프로그램 사용 > gstreamer' 카테고리의 다른 글

GstPipelineStudio on odroidc2  (0) 2025.09.21
GstPipelineStudio install on armbian  (0) 2025.09.20
GstPipelineStudio install 실패  (0) 2025.09.20
gstpipelinestudio  (0) 2025.09.11
gstreamer 기초  (0) 2025.08.27
Posted by 구차니
Linux/Ubuntu2025. 9. 26. 18:37

타임스탬프를 매 엔터마다 강제로 넣어주고 싶을때 쓰는 유틸리티

timestamp 에서 ts를 빼온것 같은데 정작 패키지 명은 moreutils다

 

[링크 : https://da-nika.tistory.com/194]

'Linux > Ubuntu' 카테고리의 다른 글

기본 터미널 변경하기  (0) 2025.09.22
intel dri 3?  (0) 2025.08.12
csvtool  (0) 2025.07.11
ubuntu dhcp lease log  (0) 2025.07.01
우분투에서 스타크래프트 시도.. 실패  (0) 2025.06.28
Posted by 구차니
프로그램 사용/rtl-sdr2025. 9. 26. 12:17

 

openwifi: Linux mac80211 compatible full-stack IEEE802.11/Wi-Fi design based on SDR (Software Defined Radio).


[링크 : https://github.com/open-sdr/openwifi]

[링크 : https://openwifi.tech/]

 

ADALM-PLUTO

reddit에서 검색하다가 얼핏 pluto가 보였는데 이거인듯.

[링크 : https://www.digikey.kr/ko/products/detail/analog-devices-inc/ADALM-PLUTO/6624230]

 

pynq + antsdr

[링크 : https://github.com/MicroPhase/antsdr-pynq]

 

UHD가 The USRP™ Hardware Driver Repository 의 약자인가?

[링크 : https://github.com/EttusResearch/uhd]

 

일종의.. wifi 해킹 펌웨어라고 보면되려나?

Nexmon is our C-based firmware patching framework for Broadcom/Cypress WiFi chips that enables you to write your own firmware patches, for example, to enable monitor mode with radiotap headers and frame injection.

[링크 : https://github.com/seemoo-lab/nexmon]

'프로그램 사용 > rtl-sdr' 카테고리의 다른 글

rtl-sdr v3/v4  (0) 2025.10.06
gr-lora with gnuradio 성공!  (0) 2025.09.25
gnuraduio wx gui deprecated  (0) 2025.09.25
qr-lora tutorial  (0) 2025.09.25
rtlsdr + gnuradio + lora 일단.. 실패  (0) 2025.09.24
Posted by 구차니
프로그램 사용/rtl-sdr2025. 9. 25. 11:45

bandwidth 와 offset이 주요 포인트였네

채널당 125kHz 라서 bw는 125k로 넣으면 되고

offset은 variable 을 검색해서 추가하고 gqrx 에서 Peak Hold 를 켜주고 나서 어느정도 시간 수집한 이후

중심 주파수를 계산해서 원래의 주파수에서 얼마나 이동했는지를 계산하면 된다.

 

시작 꼭지가 대충 921.417로 측정되고

끝 꼭지가 대충 921.590으로 측정되니

중간은 average() 함수로 계산하고 차를 계산하면 대충 30khz. 물론 실험적으로 조금씩 이동더 시켜서 되긴했는데

이게 가끔(?) 오류나는 이유이려나?

[링크 : https://github.com/rpp0/gr-lora/wiki/Capturing-LoRa-signals-using-an-RTL-SDR-device]

 

wireshark 와 연결하기 위해서는

gnu radio 에서 'A 돋보기' 눌러 "Message Socket Sink"를 찾아 추가하고

LoRa Receiver의 오른쪽 frames와

Message Socket Sink의 왼쪽 in을 연결하고

 

wireshark의 Loopback:lo 에서 열어주면 된다.

 

먼가 파형도 보이고 ping도 보이고. 그런데 간헐적으로 piO/ 식으로 잘못 해석하는데 이유가 멀까나..

 

자세히 보면 내가 설정한 decimation 값과 매칭이 되지 않는걸로 나온다.

bandwidth를 맞춰주면 자동으로 bit per symbol , bins per symbol, samples per symbol, decimation 등이 계산되는 듯.

Using device #0 Realtek RTL2838UHIDIR SN: 00000001
Found Fitipower FC0012 tuner
Exact sample rate is: 1000000.026491 Hz
Bits (nominal) per symbol:  5
Bins per symbol:  1024
Samples per symbol:  8192
Decimation:  8
Allocating 15 zero-copy buffers
 11 21 00 70 69 6e 67 70 6f 6e 67 70 69 6e 67 70 6f 6e 67 0a (pingpongpingpong)

 

Message Socket Sink에 보면 Layer를 선택가능하게 되어있는데

 

TAP / PHY / MAC 세가지가 나온다.

 

LoRa TAP을 선택하면 아래와 같이 나오는데, 옵션들 중에서는 가장 길다.

아마도 LoRa 패킷 전체를 보여주는데 wireshark에서 해석을 못하는게 아닐뿐인가 생각된다.

 

LoRa PHY을 선택하면 데이터 앞에 11 21 00 정도 추가되어 나오고

 

LoRa MAC을 선택하면 순수한 데이터만 나온다.

 

'프로그램 사용 > rtl-sdr' 카테고리의 다른 글

rtl-sdr v3/v4  (0) 2025.10.06
wifi sdr - openwifi, antsdr 등등  (0) 2025.09.26
gnuraduio wx gui deprecated  (0) 2025.09.25
qr-lora tutorial  (0) 2025.09.25
rtlsdr + gnuradio + lora 일단.. 실패  (0) 2025.09.24
Posted by 구차니
프로그램 사용/rtl-sdr2025. 9. 25. 10:27

gnu radio 3.10 / ubuntu 22.04 사용중인데

wx gui  라는게 안보여서 찾아보니 3.8 오면서 사라졌다고 한다.

대신 qt로 대체 된다고.

 

From 3.7 to 3.8

When a flowgraph which has been generated by version 3.7 is opened in GRC version 3.8, much of the conversion process is done automatically. However, there are certain things which must be updated by hand.
  • WX GUI blocks: Since the WX GUI blocks are deprecated in version 3.8, the user must find corresponding blocks in the QT GUIs.
  • If blocks have different names between versions 3.7 and 3.8, they must be replaced by hand.

[링크 : https://wiki.gnuradio.org/index.php/Porting_Existing_Flowgraphs_to_a_Newer_Version]

[링크 : https://stackoverflow.com/questions/61355913/wx-gui-fft-sink-missing-in-gnc-for-windows]

'프로그램 사용 > rtl-sdr' 카테고리의 다른 글

wifi sdr - openwifi, antsdr 등등  (0) 2025.09.26
gr-lora with gnuradio 성공!  (0) 2025.09.25
qr-lora tutorial  (0) 2025.09.25
rtlsdr + gnuradio + lora 일단.. 실패  (0) 2025.09.24
osmo sdr  (0) 2025.09.22
Posted by 구차니
프로그램 사용/rtl-sdr2025. 9. 25. 00:13

offset을 측정해줘야 하는 듯. 비싼거 쓰면 안해줘도 된다고 하는데 드럽게 비싼녀석들이라 문제  -_-

udp를 통해 wireshark로 날릴수 있음

그나저나 bandwidth는 왜 도움말에는 없는것일까.

 

options에 grlora_rtlsdr 이 WX GUI를 생성하도록 한 것 같은데

 

어느정도 보정은 해주지만 센터에 맞출수 있도록 offset 변수를 추가해서

중심주파수를 잡도록 보정해주어야 하는 듯.

 

[링크 : https://github.com/rpp0/gr-lora/wiki/Capturing-LoRa-signals-using-an-RTL-SDR-device]

'프로그램 사용 > rtl-sdr' 카테고리의 다른 글

gr-lora with gnuradio 성공!  (0) 2025.09.25
gnuraduio wx gui deprecated  (0) 2025.09.25
rtlsdr + gnuradio + lora 일단.. 실패  (0) 2025.09.24
osmo sdr  (0) 2025.09.22
gnuradio lora  (0) 2025.09.21
Posted by 구차니